Skip to content

Commit 1d3a84b

Browse files
authored
chore(CI): migrate CB CI jobs to GHA (#821)
1 parent 2e63038 commit 1d3a84b

File tree

2 files changed

+143
-0
lines changed

2 files changed

+143
-0
lines changed

.github/workflows/ci_integration.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# This workflow runs integration tests with AWS KMS keys
2+
name: integration-tests
3+
4+
on:
5+
push:
6+
branches: [ master ]
7+
pull_request:
8+
branches: [ master ]
9+
# Run once a day
10+
schedule:
11+
- cron: '0 0 * * *'
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
20+
include:
21+
- python-version: '3.8'
22+
toxenv: 'py38-integ-slow'
23+
- python-version: '3.9'
24+
toxenv: 'py39-integ-slow'
25+
- python-version: '3.10'
26+
toxenv: 'py310-integ-slow'
27+
- python-version: '3.11'
28+
toxenv: 'py311-integ-slow'
29+
- python-version: '3.12'
30+
toxenv: 'py312-integ-slow'
31+
permissions:
32+
id-token: write
33+
contents: read
34+
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- name: Set up Python ${{ matrix.python-version }}
39+
uses: actions/setup-python@v5
40+
with:
41+
python-version: ${{ matrix.python-version }}
42+
43+
- name: Install dependencies
44+
run: |
45+
python -m pip install --upgrade pip
46+
pip install "tox < 4.0"
47+
48+
# Python no longer bundles setuptools starting in 3.12
49+
- name: Install python version specific dependencies
50+
if: matrix.python-version == '3.12'
51+
run: |
52+
pip install setuptools
53+
54+
- name: Configure AWS Credentials for Tests
55+
uses: aws-actions/configure-aws-credentials@v4
56+
with:
57+
aws-region: us-west-2
58+
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-DDBEC-Python-Role-us-west-2
59+
role-session-name: DDBEC-Python-Tests
60+
61+
- name: Test with tox
62+
env:
63+
TOXENV: ${{ matrix.toxenv }}
64+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
65+
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
66+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >-
67+
arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2
68+
run: tox
69+
70+
coverage:
71+
runs-on: ubuntu-latest
72+
steps:
73+
- uses: actions/checkout@v4
74+
75+
- name: Set up Python
76+
uses: actions/setup-python@v5
77+
with:
78+
python-version: '3.x'
79+
80+
- name: Install dependencies
81+
run: |
82+
python -m pip install --upgrade pip
83+
pip install "tox < 4.0"
84+
pip install setuptools
85+
86+
- name: Run coverage
87+
env:
88+
TOXENV: coverage
89+
run: tox

cfn/github_permissions.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
AWSTemplateFormatVersion: "2010-09-09"
2+
Description: "IAM Role for CI from Github"
3+
4+
Parameters:
5+
ProjectName:
6+
Type: String
7+
Description: A prefix that will be applied to any names
8+
Default: DDBEC-Python
9+
GitHubRepo:
10+
Type: String
11+
Description: GitHub Repo that invokes CI
12+
Default: aws/aws-dynamodb-encryption-python
13+
14+
Resources:
15+
GitHubCIRole:
16+
Type: 'AWS::IAM::Role'
17+
Properties:
18+
RoleName: !Sub "GitHub-CI-${ProjectName}-Role-${AWS::Region}"
19+
Description: "Access KMS Resources for CI from GitHub"
20+
ManagedPolicyArns:
21+
- "arn:aws:iam::370957321024:policy/KMS-Public-CMK-EncryptDecrypt-Key-Access"
22+
AssumeRolePolicyDocument: !Sub |
23+
{
24+
"Version": "2012-10-17",
25+
"Statement": [
26+
{
27+
"Effect": "Allow",
28+
"Principal": { "Federated": "arn:aws:iam::${AWS::AccountId}:oidc-provider/token.actions.githubusercontent.com" },
29+
"Action": "sts:AssumeRoleWithWebIdentity",
30+
"Condition": {
31+
"StringEquals": {
32+
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
33+
},
34+
"StringLike": {
35+
"token.actions.githubusercontent.com:sub": "repo:${GitHubRepo}:*"
36+
}
37+
}
38+
},
39+
{
40+
"Effect": "Allow",
41+
"Principal": {
42+
"AWS": "*"
43+
},
44+
"Action": "sts:AssumeRole",
45+
"Condition": {
46+
"StringEquals": {
47+
"aws:PrincipalArn": [
48+
"arn:aws:iam::${AWS::AccountId}:role/ToolsDevelopment"
49+
]
50+
}
51+
}
52+
}
53+
]
54+
}

0 commit comments

Comments
 (0)