From f770ea7980aecde9f7e5594997fd3c41dde8ad8e Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Thu, 16 Feb 2023 20:57:02 -0800 Subject: [PATCH] Add CIRCT to CI and update CI versions (#393) * Add CIRCT to CI and update CI versions * Fix CI sentinel to work properly --- .github/workflows/install-circt/action.yml | 25 +++++++++ .github/workflows/test.yml | 64 ++++++++++++++++------ 2 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/install-circt/action.yml diff --git a/.github/workflows/install-circt/action.yml b/.github/workflows/install-circt/action.yml new file mode 100644 index 000000000..8a5eff9cf --- /dev/null +++ b/.github/workflows/install-circt/action.yml @@ -0,0 +1,25 @@ +name: Install CIRCT + +inputs: + version: + description: 'version to install' + required: false + default: 'firtool-1.30.0' + +runs: + using: composite + steps: + - id: cache-circt + uses: actions/cache@v3 + with: + path: circt + key: circt-${{ runner.os }}-${{ inputs.version }} + + - shell: bash + if: steps.cache-circt.outputs.cache-hit != 'true' + run: | + mkdir circt + wget -q -O - https://github.com/llvm/circt/releases/download/${{ inputs.version }}/circt-bin-ubuntu-20.04.tar.gz | tar -zx -C circt/ + + - shell: bash + run: echo "$(pwd)/circt/bin" >> $GITHUB_PATH diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cd1323071..074984106 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,20 +16,20 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Scala - uses: olafurpg/setup-scala@v10 + uses: actions/setup-java@v3 with: - java-version: adopt@1.8 - - name: Cache Scala - uses: coursier/cache-action@v5 + distribution: 'adopt' + java-version: '8' + cache: 'sbt' - name: Calculate API Docs Cache Key id: calc-key run: | KEY=$(make --always-make --dry-run apis-${{ matrix.project }} | sha256sum | awk '{print $1}') echo "::set-output name=cache_key::${KEY}" - name: Cache API Docs - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: build/api/${{ matrix.project }} key: ${{ runner.os }}-${{ matrix.project }}-${{ steps.calc-key.outputs.cache_key }} @@ -41,7 +41,7 @@ jobs: - name: Tar build artifacts run: tar zcf build/api/${{ matrix.project }}.tar.gz build/api/${{ matrix.project }} - name: Share API Docs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: ${{ matrix.project }}-api-docs path: build/api/${{ matrix.project }}.tar.gz @@ -53,13 +53,15 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Scala - uses: olafurpg/setup-scala@v10 + uses: actions/setup-java@v3 with: - java-version: adopt@1.8 - - name: Cache Scala - uses: coursier/cache-action@v5 + distribution: 'adopt' + java-version: '8' + cache: 'sbt' + - name: Install CIRCT + uses: ./.github/workflows/install-circt - name: Setup Ruby uses: actions/setup-ruby@v1 - name: Setup Jekyll @@ -67,7 +69,7 @@ jobs: gem install jekyll -v 4.2.0 gem install jekyll-redirect-from - name: Download all built API docs - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: path: artifacts - name: Untar build artifacts @@ -85,13 +87,39 @@ jobs: FOLDER: docs/target/site # Sentinel job to simplify how we specify which checks need to pass in branch - # protection and in Mergify + # protection. This job checks that all jobs were successful. # # When adding new jobs, please add them to `needs` below - all_tests_passed: - name: "all tests passed" + check-tests: + name: "check tests" needs: [api-docs, website] - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 + if: success() # only run if all tests have passed + outputs: + success: ${{ steps.setoutput.outputs.success }} steps: - - run: echo Success! + - id: setoutput + run: echo "success=true" >> $GITHUB_OUTPUT + # Related to check-tests above, this job _always_ runs (even if tests fail + # and thus check-steps is skipped). This two sentinel job approach avoids an + # issue where failing tests causes a single sentinel job to be skipped which + # counts as passing for purposes of branch protection. + # + # See: https://brunoscheufler.com/blog/2022-04-09-the-required-github-status-check-that-wasnt + all_tests_passed: + name: "all tests passed" + runs-on: ubuntu-20.04 + if: always() # Always run so that we never skip this check + needs: check-tests + # Pass only if check-tests set its output value + steps: + - run: | + PASSED="${{ needs.check-tests.outputs.success }}" + if [[ $PASSED == "true" ]]; then + echo "### All tests passed! :rocket:" >> $GITHUB_STEP_SUMMARY + exit 0 + else + echo "### One or more tests FAILED! :bangbang:" >> $GITHUB_STEP_SUMMARY + exit 1 + fi