From faf18d987339726762433e186b6327818c48a38a Mon Sep 17 00:00:00 2001 From: Andrei Malashkin Date: Thu, 6 Jun 2024 23:21:24 +0200 Subject: [PATCH 1/3] add mac build job --- .../{run_tests.yml => run_tests_linux.yml} | 3 +- .github/workflows/run_tests_mac.yml | 78 +++++++++++++++++++ 2 files changed, 80 insertions(+), 1 deletion(-) rename .github/workflows/{run_tests.yml => run_tests_linux.yml} (94%) create mode 100644 .github/workflows/run_tests_mac.yml diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests_linux.yml similarity index 94% rename from .github/workflows/run_tests.yml rename to .github/workflows/run_tests_linux.yml index 3eb8ddc18..17a772dc9 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests_linux.yml @@ -14,6 +14,7 @@ env: SUITE_REPO: "NilFoundation/crypto3" LIB_NAME: "blueprint" CACHE_NAME: "blueprint-job-cache" + TESTS_ARTIFACT_NAME: "test-results-linux" jobs: handle-syncwith: @@ -26,6 +27,7 @@ jobs: build-and-test: needs: [ handle-syncwith ] + name: "Build and test Linux" runs-on: ["self-hosted", "aws_autoscaling"] strategy: fail-fast: false @@ -33,7 +35,6 @@ jobs: # https://github.com/actions/checkout/issues/1552 - name: Clean up after previous checkout run: chmod +w -R ${GITHUB_WORKSPACE}; rm -rf ${GITHUB_WORKSPACE}/*; - - name: Checkout Blueprint uses: actions/checkout@v4 with: diff --git a/.github/workflows/run_tests_mac.yml b/.github/workflows/run_tests_mac.yml new file mode 100644 index 000000000..b4842d794 --- /dev/null +++ b/.github/workflows/run_tests_mac.yml @@ -0,0 +1,78 @@ +name: Run tests + +on: + # Triggers the workflow on pull request events but only for the master branch + pull_request: + branches: [ master ] + push: + branches: [ master ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +env: + SUITE_REPO: "NilFoundation/crypto3" + LIB_NAME: "blueprint" + CACHE_NAME: "blueprint-job-cache" + TESTS_ARTIFACT_NAME: "test-results-mac" + +jobs: + handle-syncwith: + if: github.event_name == 'pull_request' + name: Call Reusable SyncWith Handler + uses: NilFoundation/ci-cd/.github/workflows/reusable-handle-syncwith.yml@v1 + with: + ci-cd-ref: 'v1' + secrets: inherit + + build-and-test: + needs: [ handle-syncwith ] + name: "Build and test macOS" + runs-on: [macos-14] + strategy: + fail-fast: false + steps: + # https://github.com/actions/checkout/issues/1552 + - name: Clean up after previous checkout + run: chmod +w -R ${GITHUB_WORKSPACE}; rm -rf ${GITHUB_WORKSPACE}/*; + + - name: Checkout Blueprint + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive + + - name: Checkout submodules to specified refs + if: inputs.submodules-refs != '' + uses: NilFoundation/ci-cd/actions/recursive-checkout@v1.2.1 + with: + refs: ${{ inputs.submodules-refs }} + paths: | + ${{ github.workspace }}/** + !${{ github.workspace }}/ + !${{ github.workspace }}/**/.git/** + + # nix is taken from the cloud-init template, no need to install it. + - name: Build and run tests + run: | + nix build -L .?submodules=1#checks.aarch64-darwin.$check_name + results_dir="./results" + mkdir -p "$results_dir" + cp -r ./result/* "$results_dir/all-checks" + rm -rf result + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action/linux@v2 + with: + check_name: "Mac Test Results" + files: "results/**/*.xml" + comment_mode: ${{ github.event.pull_request.head.repo.fork && 'off' || 'always' }} # Don't create PR comment from fork runs + action_fail_on_inconclusive: true # fail, if no reports + action_fail: true + - name: 'Upload Artifacts' + uses: actions/upload-artifact@v4 + with: + name: junit-test-results + path: "results/**/*.xml" + retention-days: 5 + if-no-files-found: error + overwrite: true From 4e6f3e6a7b4880279e8b8ae1f474c2f1c265a787 Mon Sep 17 00:00:00 2001 From: Andrei Malashkin Date: Thu, 6 Jun 2024 23:29:22 +0200 Subject: [PATCH 2/3] handle syncwith separately --- .github/workflows/pull-request.yml | 48 +++++++++++++++++++++++++++ .github/workflows/run_tests_linux.yml | 26 ++++----------- .github/workflows/run_tests_mac.yml | 30 ++++------------- 3 files changed, 62 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/pull-request.yml diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 000000000..91cc638cf --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,48 @@ +name: PR Testing + +on: + pull_request: + push: + branches: + - master + +concurrency: + # In master we want to run for every commit, in other branches — only for the last one + group: ${{ + ( github.ref == 'refs/heads/master' && format('{0}/{1}/{2}', github.workflow, github.ref, github.sha) ) + || + format('{0}/{1}', github.workflow, github.ref) }} + cancel-in-progress: true + +jobs: + handle-syncwith: + if: github.event_name == 'pull_request' + name: Call Reusable SyncWith Handler + uses: NilFoundation/ci-cd/.github/workflows/reusable-handle-syncwith.yml@v1.2.1 + with: + ci-cd-ref: 'v1.1.2' + secrets: inherit + + test-linux: + name: Linux Crypto3 Testing + uses: ./.github/workflows/run_tests_linux.yml + needs: + - handle-syncwith + if: | + always() && !cancelled() && + (needs.handle-syncwith.result == 'success' || needs.handle-syncwith.result == 'skipped') + secrets: inherit + with: + submodules-refs: ${{ needs.handle-syncwith.outputs.prs-refs }} + + test-mac: + name: macOS Crypto3 Testing + uses: ./.github/workflows/run_tests_mac.yml + needs: + - handle-syncwith + if: | + always() && !cancelled() && + (needs.handle-syncwith.result == 'success' || needs.handle-syncwith.result == 'skipped') + secrets: inherit + with: + submodules-refs: ${{ needs.handle-syncwith.outputs.prs-refs }} diff --git a/.github/workflows/run_tests_linux.yml b/.github/workflows/run_tests_linux.yml index 17a772dc9..652d63001 100644 --- a/.github/workflows/run_tests_linux.yml +++ b/.github/workflows/run_tests_linux.yml @@ -1,32 +1,20 @@ -name: Run tests +name: Run linux tests on: - # Triggers the workflow on pull request events but only for the master branch - pull_request: - branches: [ master ] - push: - branches: [ master ] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: + workflow_call: + inputs: + submodules-refs: + type: string + description: "Lines with submodules' repo names and refs (e.g. `org/repo: ref`)" + required: false env: - SUITE_REPO: "NilFoundation/crypto3" LIB_NAME: "blueprint" CACHE_NAME: "blueprint-job-cache" TESTS_ARTIFACT_NAME: "test-results-linux" jobs: - handle-syncwith: - if: github.event_name == 'pull_request' - name: Call Reusable SyncWith Handler - uses: NilFoundation/ci-cd/.github/workflows/reusable-handle-syncwith.yml@v1 - with: - ci-cd-ref: 'v1' - secrets: inherit - build-and-test: - needs: [ handle-syncwith ] name: "Build and test Linux" runs-on: ["self-hosted", "aws_autoscaling"] strategy: diff --git a/.github/workflows/run_tests_mac.yml b/.github/workflows/run_tests_mac.yml index b4842d794..0b970b73f 100644 --- a/.github/workflows/run_tests_mac.yml +++ b/.github/workflows/run_tests_mac.yml @@ -1,41 +1,25 @@ -name: Run tests +name: Run mac tests on: - # Triggers the workflow on pull request events but only for the master branch - pull_request: - branches: [ master ] - push: - branches: [ master ] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: + workflow_call: + inputs: + submodules-refs: + type: string + description: "Lines with submodules' repo names and refs (e.g. `org/repo: ref`)" + required: false env: - SUITE_REPO: "NilFoundation/crypto3" LIB_NAME: "blueprint" CACHE_NAME: "blueprint-job-cache" TESTS_ARTIFACT_NAME: "test-results-mac" jobs: - handle-syncwith: - if: github.event_name == 'pull_request' - name: Call Reusable SyncWith Handler - uses: NilFoundation/ci-cd/.github/workflows/reusable-handle-syncwith.yml@v1 - with: - ci-cd-ref: 'v1' - secrets: inherit - build-and-test: - needs: [ handle-syncwith ] name: "Build and test macOS" runs-on: [macos-14] strategy: fail-fast: false steps: - # https://github.com/actions/checkout/issues/1552 - - name: Clean up after previous checkout - run: chmod +w -R ${GITHUB_WORKSPACE}; rm -rf ${GITHUB_WORKSPACE}/*; - - name: Checkout Blueprint uses: actions/checkout@v4 with: From e50271acbf2f917c9498e21a0d6830a9e7211814 Mon Sep 17 00:00:00 2001 From: Andrei Malashkin Date: Thu, 6 Jun 2024 23:35:57 +0200 Subject: [PATCH 3/3] add nix install to mac --- .github/workflows/run_tests_mac.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_tests_mac.yml b/.github/workflows/run_tests_mac.yml index 0b970b73f..a9dedd116 100644 --- a/.github/workflows/run_tests_mac.yml +++ b/.github/workflows/run_tests_mac.yml @@ -35,11 +35,13 @@ jobs: ${{ github.workspace }}/** !${{ github.workspace }}/ !${{ github.workspace }}/**/.git/** - + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + - uses: DeterminateSystems/flake-checker-action@main # nix is taken from the cloud-init template, no need to install it. - name: Build and run tests run: | - nix build -L .?submodules=1#checks.aarch64-darwin.$check_name + nix build -L .?submodules=1#checks.aarch64-darwin.default results_dir="./results" mkdir -p "$results_dir" cp -r ./result/* "$results_dir/all-checks"