Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 11cd1b6

Browse files
committed
Add testing workflow
1 parent 4283dda commit 11cd1b6

File tree

3 files changed

+192
-0
lines changed

3 files changed

+192
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Crypto3 Build and Test on Linux Platforms
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
submodules-refs:
7+
type: string
8+
description: "Lines with submodules' repo names and refs (e.g. `org/repo: ref`)"
9+
required: false
10+
11+
env:
12+
TESTS_ARTIFACT_NAME: "test-results-linux"
13+
14+
jobs:
15+
build-and-test:
16+
name: "Build and test Linux"
17+
runs-on: [self-hosted, Linux, X64, aws_autoscaling]
18+
steps:
19+
# https://github.com/actions/checkout/issues/1552
20+
- name: Clean up after previous checkout
21+
run: chmod +w -R ${GITHUB_WORKSPACE}; rm -rf ${GITHUB_WORKSPACE}/*;
22+
23+
- name: Checkout Crypto3
24+
uses: actions/checkout@v3
25+
with:
26+
fetch-depth: 0
27+
submodules: recursive
28+
29+
- name: Checkout submodules to specified refs
30+
if: inputs.submodules-refs != ''
31+
uses: NilFoundation/ci-cd/actions/[email protected]
32+
with:
33+
refs: ${{ inputs.submodules-refs }}
34+
paths: |
35+
${{ github.workspace }}/**
36+
!${{ github.workspace }}/
37+
!${{ github.workspace }}/**/.git/**
38+
39+
- name: Run checks
40+
run: nix flake -L check .?submodules=1#
41+
env:
42+
NIX_CONFIG: |
43+
cores = 6
44+
max-jobs = 4
45+
46+
- name: Copy test results
47+
run: |
48+
check_names=(
49+
"containers-clang"
50+
"math-clang"
51+
"zk-clang"
52+
"containers-gcc"
53+
"math-gcc"
54+
"zk-gcc"
55+
)
56+
57+
results_dir="./results"
58+
mkdir -p "$results_dir"
59+
60+
for check_name in "${check_names[@]}"; do
61+
# This completes immediately since results are in cache
62+
nix build -L .?submodules=1#checks.x86_64-linux.$check_name
63+
cp -r ./result/* "$results_dir/$check_name"
64+
rm result
65+
done
66+
67+
- name: Publish Test Results
68+
uses: EnricoMi/publish-unit-test-result-action/linux@v2
69+
with:
70+
check_name: "Linux Test Results"
71+
files: "results/**/*.xml"
72+
comment_mode: ${{ github.event.pull_request.head.repo.fork && 'off' || 'always' }} # Don't create PR comment from fork runs
73+
action_fail_on_inconclusive: true # fail, if no reports
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Crypto3 Build and Test on macOS Platforms
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
submodules-refs:
7+
type: string
8+
description: "Lines with submodules' repo names and refs (e.g. `org/repo: ref`)"
9+
required: false
10+
11+
env:
12+
TESTS_ARTIFACT_NAME: "test-results-mac"
13+
14+
jobs:
15+
build-and-test:
16+
name: "Build and test macOS"
17+
runs-on: [macos-14]
18+
steps:
19+
- name: Checkout Crypto3
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
submodules: recursive
24+
25+
- name: Checkout submodules to specified refs
26+
if: inputs.submodules-refs != ''
27+
uses: NilFoundation/ci-cd/actions/[email protected]
28+
with:
29+
refs: ${{ inputs.submodules-refs }}
30+
paths: |
31+
${{ github.workspace }}/**
32+
!${{ github.workspace }}/
33+
!${{ github.workspace }}/**/.git/**
34+
35+
# From https://github.com/DeterminateSystems/magic-nix-cache-action
36+
- uses: DeterminateSystems/nix-installer-action@main
37+
- uses: DeterminateSystems/magic-nix-cache-action@main
38+
- uses: DeterminateSystems/flake-checker-action@main
39+
40+
- name: Run checks
41+
run: nix flake -L check .?submodules=1#
42+
env:
43+
NIX_CONFIG: |
44+
cores = 0
45+
max-jobs = 1
46+
47+
- name: Copy test results
48+
run: |
49+
check_names=(
50+
"containers-clang"
51+
"math-clang"
52+
"zk-clang"
53+
)
54+
55+
results_dir="./results"
56+
mkdir -p "$results_dir"
57+
58+
for check_name in "${check_names[@]}"; do
59+
# This completes immediately since results are in cache
60+
nix build -L .?submodules=1#checks.aarch64-darwin.$check_name
61+
cp -r ./result/* "$results_dir/$check_name"
62+
rm result
63+
done
64+
65+
- name: Publish Test Results
66+
uses: EnricoMi/publish-unit-test-result-action/linux@v2
67+
with:
68+
check_name: "Mac Test Results"
69+
files: "results/**/*.xml"
70+
comment_mode: ${{ github.event.pull_request.head.repo.fork && 'off' || 'always' }} # Don't create PR comment from fork runs
71+
action_fail_on_inconclusive: true # fail, if no reports

.github/workflows/pull-request.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: PR Testing
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
concurrency:
10+
# In master we want to run for every commit, in other branches — only for the last one
11+
group: ${{
12+
( github.ref == 'refs/heads/master' && format('{0}/{1}/{2}', github.workflow, github.ref, github.sha) )
13+
||
14+
format('{0}/{1}', github.workflow, github.ref) }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
handle-syncwith:
19+
if: github.event_name == 'pull_request'
20+
name: Call Reusable SyncWith Handler
21+
uses: NilFoundation/ci-cd/.github/workflows/[email protected]
22+
with:
23+
ci-cd-ref: 'v1.1.2'
24+
secrets: inherit
25+
26+
test-linux:
27+
name: Linux Crypto3 Testing
28+
uses: ./.github/workflows/crypto3-testing-linux.yml
29+
needs:
30+
- handle-syncwith
31+
if: |
32+
always() && !cancelled() &&
33+
(needs.handle-syncwith.result == 'success' || needs.handle-syncwith.result == 'skipped')
34+
secrets: inherit
35+
with:
36+
submodules-refs: ${{ needs.handle-syncwith.outputs.prs-refs }}
37+
38+
test-mac:
39+
name: macOS Crypto3 Testing
40+
uses: ./.github/workflows/crypto3-testing-mac.yml
41+
needs:
42+
- handle-syncwith
43+
if: |
44+
always() && !cancelled() &&
45+
(needs.handle-syncwith.result == 'success' || needs.handle-syncwith.result == 'skipped')
46+
secrets: inherit
47+
with:
48+
submodules-refs: ${{ needs.handle-syncwith.outputs.prs-refs }}

0 commit comments

Comments
 (0)