From b0a163f76372bf77ca75a0af8c43d9fbc56e3258 Mon Sep 17 00:00:00 2001 From: Rafael Sene Date: Mon, 10 Jun 2024 19:30:23 -0300 Subject: [PATCH] Upgrade the build process via GitHub Actions This commit upgrades the build process by replacing the previous approach with a new one, using a single GitHub Action. Signed-off-by: Rafael Sene --- .github/workflows/compile.yml | 34 --------------- .github/workflows/sail-ci.yml | 66 ++++++++++++++++++++++++++++++ .github/workflows/test-results.yml | 51 ----------------------- 3 files changed, 66 insertions(+), 85 deletions(-) delete mode 100644 .github/workflows/compile.yml create mode 100644 .github/workflows/sail-ci.yml delete mode 100644 .github/workflows/test-results.yml diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml deleted file mode 100644 index 865c748a5..000000000 --- a/.github/workflows/compile.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: CI - -on: [push, pull_request, workflow_dispatch] - -jobs: - build: - runs-on: ubuntu-22.04 - steps: - - name: Install packages - run: sudo apt install -y opam zlib1g-dev pkg-config libgmp-dev z3 device-tree-compiler - - name: Check out repository code - uses: actions/checkout@HEAD - with: - submodules: true - - name: Ensure pre-commit checks pass - run: pip install pre-commit && pre-commit run --all-files --show-diff-on-failure --color=always - - name: Init opam - run: opam init --disable-sandboxing -y - - name: Install sail - run: opam install -y sail - - name: Build and test simulators - run: eval $(opam env) && test/run_tests.sh - - name: Upload test results - if: always() - uses: actions/upload-artifact@v4 - with: - name: tests.xml - path: test/tests.xml - - name: Upload event payload - if: always() - uses: actions/upload-artifact@v4 - with: - name: event.json - path: ${{ github.event_path }} diff --git a/.github/workflows/sail-ci.yml b/.github/workflows/sail-ci.yml new file mode 100644 index 000000000..3ca23bc58 --- /dev/null +++ b/.github/workflows/sail-ci.yml @@ -0,0 +1,66 @@ +name: SAIL CI + +on: [push, pull_request, workflow_dispatch] + +jobs: + build: + if: github.repository == 'rpsene/sail-riscv' + runs-on: ubuntu-22.04 + + steps: + - name: Check out repository code + uses: actions/checkout@v4 + with: + submodules: true + + - name: Install dependencies + id: install_dependencies + run: | + sudo apt update + sudo apt install -y opam zlib1g-dev pkg-config libgmp-dev z3 device-tree-compiler + pip install pre-commit + + - name: Ensure pre-commit checks pass + id: pre_commit + run: pre-commit run --all-files --show-diff-on-failure --color=always + + - name: Init opam + id: init_opam + run: opam init --disable-sandboxing -y + + - name: Install sail + id: install_sail + run: opam install -y sail + + - name: Build and test simulators + if: steps.install_dependencies.outcome == 'success' && steps.pre_commit.outcome == 'success' && steps.init_opam.outcome == 'success' && steps.install_sail.outcome == 'success' + id: build_test_simulators + run: eval $(opam env) && test/run_tests.sh + + - name: Upload test.xml + id: upload_test_xml + if: steps.build_test_simulators.outcome == 'success' + uses: actions/upload-artifact@v4 + with: + name: tests.xml + path: test/tests.xml + + - name: Upload event.json + id: upload_event_json + if: steps.build_test_simulators.outcome == 'success' + uses: actions/upload-artifact@v4 + with: + name: event.json + path: ${{ github.event_path }} + + - name: Publish Test Results + if: steps.build_test_simulators.outcome == 'success' + uses: EnricoMi/publish-unit-test-result-action@v2 + with: + files: | + test/tests.xml + + - name: PR comment with file + uses: thollander/actions-comment-pull-request@v2 + with: + filePath: /path/to/file.txt diff --git a/.github/workflows/test-results.yml b/.github/workflows/test-results.yml deleted file mode 100644 index 4201d46e5..000000000 --- a/.github/workflows/test-results.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Publish test results - -on: - workflow_run: - workflows: ["CI"] - types: - - completed - -jobs: - publish-test-results: - runs-on: ubuntu-latest - if: github.event.workflow_run.conclusion != 'skipped' - steps: - - name: Download artifacts - uses: actions/github-script@v6 - with: - script: | - var fs = require('fs'); - var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: ${{github.event.workflow_run.id }}, - }); - var matchArtifacts = artifacts.data.artifacts.filter((artifact) => { - return artifact.name == 'tests.xml' || artifact.name == 'event.json' - }); - var count = matchArtifacts.length; - for (var i = 0; i < count; i++) { - var matchArtifact = matchArtifacts[i]; - var download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifact.id, - archive_format: 'zip', - }); - var name = matchArtifact.name; - var dest = name + '.zip' - fs.writeFileSync('${{github.workspace}}/' + dest, Buffer.from(download.data)); - console.log("Downloaded", name, "as", dest); - } - - name: Extract test results - run: unzip tests.xml.zip - - name: Extract event payload - run: unzip event.json.zip - - name: Publish test results - uses: EnricoMi/publish-unit-test-result-action@v2 - with: - commit: ${{ github.event.workflow_run.head_sha }} - event_file: event.json - event_name: ${{ github.event.workflow_run.event }} - files: tests.xml