-
Notifications
You must be signed in to change notification settings - Fork 313
175 lines (172 loc) · 5.67 KB
/
main.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: main
env:
AWS_REGION: us-east-1
AWS_ROLE_DURATION: 3600
# role generated from https://github.com/Sceptre/sceptre-aws/blob/master/config/prod/gh-oidc-sceptre-tests.yaml
AWS_ROLE: arn:aws:iam::743644221192:role/gh-oidc-sceptre-tests
on:
push:
branches:
- '*'
tags:
- 'v[0-9]+.[0-9]+.[0-9]+([0-9]+)'
pull_request:
branches:
- '*'
jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: poetry install --no-interaction --all-extras
- name: run pre-commit
run: poetry run pre-commit run --all-files --show-diff-on-failure
packaging:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: poetry install --no-interaction --all-extras
- name: build package
run: poetry build
documentation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: poetry install --no-interaction --all-extras
- name: build documentation
run: poetry run make html --directory docs
unit-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Setup Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: poetry install --no-interaction --all-extras
- name: run python tests
run: poetry run tox -e py
- name: run python test report
run: poetry run tox -e report
docker-build:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Build Docker Image
uses: docker/build-push-action@v5
with:
context: .
integration-tests:
needs:
- linting
- packaging
- documentation
- unit-tests
- docker-build
if: ${{ github.ref_type == 'push' }}
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: poetry install --no-interaction --all-extras
# Update poetry for https://github.com/python-poetry/poetry/issues/7184
- name: update poetry
run: poetry self update --no-ansi
- name: Setup Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'poetry'
- name: Assume AWS role
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: ${{ env.AWS_ROLE }}
role-session-name: GHA-${{ github.repository_owner }}-${{ github.event.repository.name }}-${{ github.run_id }}
role-duration-seconds: ${{ env.AWS_ROLE_DURATION }}
- name: run tests
run: AWS_DEFAULT_REGION=eu-west-1 poetry run behave integration-tests/features --junit --junit-directory build/behave
docker-build-push:
needs:
- integration-tests
if: ${{ (github.ref_type == 'push') && (github.ref == 'refs/heads/master') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
- name: Build and push Docker image to sceptreorg/sceptre:${{ steps.meta.outputs.tags }}
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: sceptreorg/sceptre:${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
docker-build-release:
if: ${{ github.ref_type == 'tag' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
- name: Build and push Docker image to sceptreorg/sceptre:latest
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: sceptreorg/sceptre:latest
labels: ${{ steps.meta.outputs.labels }}
- name: Build and push Docker image to sceptreorg/sceptre:${{ steps.meta.outputs.tags }}
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: sceptreorg/sceptre:${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
pypi-release:
if: ${{ github.ref_type == 'tag' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: poetry install --no-interaction --all-extras
- name: Publish to pypi
run: poetry publish --build -u __token__ -p ${{ secrets.PYPI_API_TOKEN }}