Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e2f2b3b

Browse files
refactor(GHA): make workflows reusable (#1182)
1 parent e7801ec commit e2f2b3b

20 files changed

+663
-186
lines changed

‎.github/workflows/check-files.yml‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# This workflow checks if specfic files were modified,
2+
# if they were they require more than one approval from CODEOWNERS
3+
name: Check Release Files
4+
5+
on:
6+
pull_request:
7+
8+
jobs:
9+
require-approvals:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
issues: write
13+
pull-requests: write
14+
env:
15+
# unfortunately we can't check if the approver is part of the CODEOWNERS. This is a subset of aws/aws-crypto-tools-team
16+
# to add more allowlisted approvers just modify this env variable
17+
maintainers: seebees, texastony, ShubhamChaturvedi7, lucasmcdonald3, josecorella, imabhichow, rishav-karanjit, antonf-amzn, justplaz, ajewellamz
18+
steps:
19+
- uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Get Files changed
24+
id: file-changes
25+
shell: bash
26+
run:
27+
# *release.yml files are responsible for releasing builds
28+
# we require multiple approvers if any of those files change
29+
# when adding any release file, it must be appended with *release
30+
# we also want to check if there are changes to this file
31+
echo "FILES=$(git diff --name-only origin/main origin/${GITHUB_HEAD_REF} .github/workflows/*release.yml .github/workflows/check-files.yml | tr '\n' ' ')" >> "$GITHUB_OUTPUT"
32+
33+
- name: Check if FILES is not empty
34+
id: comment
35+
env:
36+
PR_NUMBER: ${{ github.event.number }}
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
FILES: ${{ steps.file-changes.outputs.FILES }}
39+
if: ${{env.FILES != ''}}
40+
run: |
41+
COMMENT="Detected changes to the release files or to the check-files action"
42+
COMMENT_URL="https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments"
43+
curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST $COMMENT_URL -d "{\"body\":\"$COMMENT\"}"
44+
45+
- name: Check Approvers
46+
id: approvers
47+
if: steps.comment.outcome == 'success'
48+
# if this step fails we want to continue to post a message on the PR.
49+
continue-on-error: true
50+
# we are using this action because it does the heavy lifting for us, it uses the github_token enabled
51+
# for github actions, this is ok because tokens are created for every workflow run and they expire at the end
52+
# of the job
53+
uses: peternied/required-approval@v1.3
54+
with:
55+
token: ${{ secrets.GITHUB_TOKEN }}
56+
min-required: 2
57+
required-approvers-list: ${{env.maintainers}}
58+
59+
- name: Post Approvers Result
60+
if: steps.approvers.outcome == 'failure'
61+
env:
62+
PR_NUMBER: ${{ github.event.number }}
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
run: |
65+
COMMENT="Changes to the release files or the check-files action requires 2 approvals from CODEOWNERS"
66+
COMMENT_URL="https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments"
67+
curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST $COMMENT_URL -d "{\"body\":\"$COMMENT\"}"
68+
exit 1

‎.github/workflows/ci_codegen.yml‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# This workflow regenerates code using smithy-dafny and checks that the output matches what's checked in.
22
name: Library Code Generation
33
on:
4-
pull_request:
5-
push:
6-
branches:
7-
- main
4+
workflow_call:
5+
inputs:
6+
dafny:
7+
description: "The dafny version to run"
8+
required: true
9+
type: string
810

911
jobs:
1012
code-generation:
@@ -38,7 +40,7 @@ jobs:
3840
- name: Setup Dafny
3941
uses: dafny-lang/setup-dafny-action@v1.7.0
4042
with:
41-
dafny-version: 4.2.0
43+
dafny-version: ${{ inputs.dafny }}
4244

4345
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
4446
uses: actions/setup-dotnet@v4

‎.github/workflows/ci_examples_java.yml‎

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,20 @@
22
name: Java Examples
33

44
on:
5-
pull_request:
6-
push:
7-
branches:
8-
- main
9-
workflow_dispatch:
10-
# Manual trigger for this workflow, either the normal version
11-
# or the nightly build that uses the latest Dafny prerelease
12-
# (accordingly to the "nightly" parameter).
5+
workflow_call:
136
inputs:
14-
nightly:
15-
description: "Run the nightly build"
7+
dafny:
8+
description: "The Dafny version to run"
9+
required: true
10+
type: string
11+
regenerate-code:
12+
description: "Regenerate code using smithy-dafny"
1613
required: false
14+
default: false
1715
type: boolean
18-
schedule:
19-
# Nightly build against Dafny's nightly prereleases,
20-
# for early warning of verification issues or regressions.
21-
# Timing chosen to be adequately after Dafny's own nightly build,
22-
# but this might need to be tweaked:
23-
# https://github.com/dafny-lang/dafny/blob/master/.github/workflows/deep-tests.yml#L16
24-
- cron: "30 16 * * *"
2516

2617
jobs:
2718
testJava:
28-
# Don't run the nightly build on forks
29-
if: github.event_name != 'schedule' || github.repository_owner == 'aws'
3019
strategy:
3120
max-parallel: 1
3221
matrix:
@@ -57,11 +46,10 @@ jobs:
5746
- name: Setup Dafny
5847
uses: dafny-lang/setup-dafny-action@v1.7.0
5948
with:
60-
# A && B || C is the closest thing to an if .. then ... else ... or ?: expression the GitHub Actions syntax supports.
61-
dafny-version: ${{ (github.event_name == 'schedule' || inputs.nightly) && 'nightly-latest' || '4.2.0' }}
49+
dafny-version: ${{ inputs.dafny }}
6250

6351
- name: Regenerate code using smithy-dafny if necessary
64-
if: ${{ github.event_name == 'schedule' || inputs.nightly }}
52+
if: ${{ inputs.regenerate-code }}
6553
uses: ./.github/actions/polymorph_codegen
6654
with:
6755
dafny: ${{ env.DAFNY_VERSION }}

‎.github/workflows/ci_examples_net.yml‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22
name: dotnet examples
33

44
on:
5-
pull_request:
6-
push:
7-
branches:
8-
- main
5+
workflow_call:
6+
inputs:
7+
dafny:
8+
description: "The Dafny version to run"
9+
required: true
10+
type: string
11+
regenerate-code:
12+
description: "Regenerate code using smithy-dafny"
13+
required: false
14+
default: false
15+
type: boolean
916

1017
jobs:
1118
dotNetExamples:
@@ -36,7 +43,16 @@ jobs:
3643
- name: Setup Dafny
3744
uses: dafny-lang/setup-dafny-action@v1.7.0
3845
with:
39-
dafny-version: ${{ '4.2.0' }}
46+
dafny-version: ${{ inputs.dafny }}
47+
48+
- name: Regenerate code using smithy-dafny if necessary
49+
if: ${{ inputs.regenerate-code }}
50+
uses: ./.github/actions/polymorph_codegen
51+
with:
52+
dafny: ${{ env.DAFNY_VERSION }}
53+
library: DynamoDbEncryption
54+
diff-generated-code: false
55+
update-and-regenerate-mpl: true
4056

4157
- name: Download Dependencies
4258
working-directory: ./${{ matrix.library }}

‎.github/workflows/ci_test_java.yml‎

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,20 @@
22
name: Library Java tests
33

44
on:
5-
pull_request:
6-
push:
7-
branches:
8-
- main
9-
workflow_dispatch:
10-
# Manual trigger for this workflow, either the normal version
11-
# or the nightly build that uses the latest Dafny prerelease
12-
# (accordingly to the "nightly" parameter).
5+
workflow_call:
136
inputs:
14-
nightly:
15-
description: "Run the nightly build"
7+
dafny:
8+
description: "The Dafny version to run"
9+
required: true
10+
type: string
11+
regenerate-code:
12+
description: "Regenerate code using smithy-dafny"
1613
required: false
14+
default: false
1715
type: boolean
18-
schedule:
19-
# Nightly build against Dafny's nightly prereleases,
20-
# for early warning of verification issues or regressions.
21-
# Timing chosen to be adequately after Dafny's own nightly build,
22-
# but this might need to be tweaked:
23-
# https://github.com/dafny-lang/dafny/blob/master/.github/workflows/deep-tests.yml#L16
24-
- cron: "30 16 * * *"
2516

2617
jobs:
2718
testJava:
28-
# Don't run the nightly build on forks
29-
if: github.event_name != 'schedule' || github.repository_owner == 'aws'
3019
strategy:
3120
matrix:
3221
library: [DynamoDbEncryption]
@@ -51,11 +40,10 @@ jobs:
5140
- name: Setup Dafny
5241
uses: dafny-lang/setup-dafny-action@v1.7.0
5342
with:
54-
# A && B || C is the closest thing to an if .. then ... else ... or ?: expression the GitHub Actions syntax supports.
55-
dafny-version: ${{ (github.event_name == 'schedule' || inputs.nightly) && 'nightly-latest' || '4.2.0' }}
43+
dafny-version: ${{ inputs.dafny }}
5644

5745
- name: Regenerate code using smithy-dafny if necessary
58-
if: ${{ github.event_name == 'schedule' || inputs.nightly }}
46+
if: ${{ inputs.regenerate-code }}
5947
uses: ./.github/actions/polymorph_codegen
6048
with:
6149
dafny: ${{ env.DAFNY_VERSION }}

‎.github/workflows/ci_test_net.yml‎

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,20 @@
22
name: test dotnet
33

44
on:
5-
pull_request:
6-
push:
7-
branches:
8-
- main
9-
workflow_dispatch:
10-
# Manual trigger for this workflow, either the normal version
11-
# or the nightly build that uses the latest Dafny prerelease
12-
# (accordingly to the "nightly" parameter).
5+
workflow_call:
136
inputs:
14-
nightly:
15-
description: "Run the nightly build"
7+
dafny:
8+
description: "The Dafny version to run"
9+
required: true
10+
type: string
11+
regenerate-code:
12+
description: "Regenerate code using smithy-dafny"
1613
required: false
14+
default: false
1715
type: boolean
18-
schedule:
19-
# Nightly build against Dafny's nightly prereleases,
20-
# for early warning of verification issues or regressions.
21-
# Timing chosen to be adequately after Dafny's own nightly build,
22-
# but this might need to be tweaked:
23-
# https://github.com/dafny-lang/dafny/blob/master/.github/workflows/deep-tests.yml#L16
24-
- cron: "30 16 * * *"
2516

2617
jobs:
2718
testDotNet:
28-
# Don't run the nightly build on forks
29-
# Disabled until we reintroduce DynamoDbEncryption, since a matrix vector cannot be empty
30-
if: (github.event_name != 'schedule' || github.repository_owner == 'aws')
3119
strategy:
3220
matrix:
3321
library: [DynamoDbEncryption]
@@ -56,11 +44,10 @@ jobs:
5644
- name: Setup Dafny
5745
uses: dafny-lang/setup-dafny-action@v1.7.0
5846
with:
59-
# A && B || C is the closest thing to an if .. then ... else ... or ?: expression the GitHub Actions syntax supports.
60-
dafny-version: ${{ (github.event_name == 'schedule' || inputs.nightly) && 'nightly-latest' || '4.2.0' }}
47+
dafny-version: ${{ inputs.dafny }}
6148

6249
- name: Regenerate code using smithy-dafny if necessary
63-
if: ${{ github.event_name == 'schedule' || inputs.nightly }}
50+
if: ${{ inputs.regenerate-code }}
6451
uses: ./.github/actions/polymorph_codegen
6552
with:
6653
dafny: ${{ env.DAFNY_VERSION }}

‎.github/workflows/ci_test_vector_java.yml‎

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,23 @@
22
name: Library Java Test Vectors
33

44
on:
5-
pull_request:
6-
push:
7-
branches:
8-
- main
5+
workflow_call:
6+
inputs:
7+
dafny:
8+
description: "The Dafny version to run"
9+
required: true
10+
type: string
11+
regenerate-code:
12+
description: "Regenerate code using smithy-dafny"
13+
required: false
14+
default: false
15+
type: boolean
916

1017
jobs:
1118
testJava:
1219
strategy:
1320
matrix:
21+
library: [TestVectors]
1422
java-version: [8, 11, 16, 17]
1523
os: [
1624
# Run on ubuntu image that comes pre-configured with docker
@@ -41,7 +49,16 @@ jobs:
4149
- name: Setup Dafny
4250
uses: dafny-lang/setup-dafny-action@v1.7.0
4351
with:
44-
dafny-version: "4.2.0"
52+
dafny-version: ${{ inputs.dafny }}
53+
54+
- name: Regenerate code using smithy-dafny if necessary
55+
if: ${{ inputs.regenerate-code }}
56+
uses: ./.github/actions/polymorph_codegen
57+
with:
58+
dafny: ${{ env.DAFNY_VERSION }}
59+
library: ${{ matrix.library }}
60+
diff-generated-code: false
61+
update-and-regenerate-mpl: true
4562

4663
- name: Setup Java ${{ matrix.java-version }}
4764
uses: actions/setup-java@v4
@@ -51,13 +68,13 @@ jobs:
5168

5269
- name: Build TestVectors implementation
5370
shell: bash
54-
working-directory: ./TestVectors
71+
working-directory: ${{matrix.library}}
5572
run: |
5673
# This works because `node` is installed by default on GHA runners
5774
CORES=$(node -e 'console.log(os.cpus().length)')
5875
make build_java CORES=$CORES
5976
6077
- name: Test TestVectors
61-
working-directory: ./TestVectors
78+
working-directory: ${{matrix.library}}
6279
run: |
6380
make test_java

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /