-
Notifications
You must be signed in to change notification settings - Fork 1
187 lines (161 loc) · 6.29 KB
/
test.yml
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
176
177
178
179
180
181
182
183
184
185
186
187
# This is a workflow for ensuring tests pass all supported environments.
---
name: Test
on:
# Allow running this workflow manually from the Actions tab
workflow_dispatch:
pull_request:
push:
branches:
- main
defaults:
run:
shell: bash
jobs:
QA:
name: Quality Assurance
runs-on: ubuntu-latest
strategy:
matrix:
# It's only one Python version specified in a "matrix", but on purpose to stay DRY
python-version: ["3.11"]
steps:
- name: Checkout the repo
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Install poetry
run: pipx install poetry==1.6.1
- name: Configure poetry
run: poetry config virtualenvs.in-project true
- name: Set up Python
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Install the project with poetry
run: |
poetry env use python${{ matrix.python-version }}
poetry check --lock
poetry lock --no-update --no-cache
poetry install --verbose --no-root --sync --with qa
- name: Run tox via poetry
env:
# Skip the `phylum-ci` pre-commit hook since:
# * The current GitHub integration expects to *only* be run in a PR context
# * The `phylum-ci` action will already be run for pull request triggers
# Skip the `no-commit-to-branch` pre-commit hook since:
# * It will cause failures in CI when merging a PR back to `main`
# * The hook is meant to be used locally, where blocking before CI can run is the goal
SKIP: phylum-ci,no-commit-to-branch
# Add annotations to the PR for any findings
RUFF_FORMAT: github
run: poetry run tox run -e qa
test-matrix:
name: Test on Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- name: Checkout the repo
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Install poetry
run: pipx install poetry==1.6.1
- name: Configure poetry
run: poetry config virtualenvs.in-project true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Install the project with poetry
run: |
poetry env use python${{ matrix.python-version }}
poetry check --lock
poetry lock --no-update --no-cache
poetry install --verbose --no-root --sync --with test,ci
- name: Run tox via poetry
run: poetry run tox
# This job is meant to be a sanity check on the Docker image...that it can be created and
# have the script entry points called without error.
docker:
name: Docker smoke test
runs-on: ubuntu-latest
strategy:
matrix:
# It's only one Python version specified in a "matrix", but on purpose to stay DRY
python-version: ["3.11"]
env:
DOCKER_BUILDKIT: 1
steps:
- name: Checkout the repo
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Install poetry
run: pipx install poetry==1.6.1
- name: Configure poetry
run: poetry config virtualenvs.in-project true
- name: Set up Python
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Install the project with poetry
run: |
poetry env use python${{ matrix.python-version }}
poetry check --lock
poetry lock --no-update --no-cache
poetry install --verbose --no-root --sync
- name: Build docker image from source
run: |
docker build \
--tag phylum-ci:from-src \
--cache-from phylumio/phylum-ci:latest \
--build-arg GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
.
- name: Test docker image built from source
run: |
docker run --rm phylum-ci:from-src git --version
docker run --rm phylum-ci:from-src phylum-ci --version
docker run --rm phylum-ci:from-src phylum-ci --help
docker run --rm phylum-ci:from-src phylum-init --help
docker run --rm phylum-ci:from-src phylum --help
- name: Build wheel and source distribution
run: poetry build -vvv
- name: Build docker image with pre-built distributions
run: |
docker build \
--tag phylum-ci:from-dist \
--cache-from phylumio/phylum-ci:latest \
--build-arg PKG_SRC=dist/phylum-*.whl \
--build-arg PKG_NAME=phylum-*.whl \
--build-arg GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
.
- name: Test docker image built from dist
run: |
docker run --rm phylum-ci:from-dist git --version
docker run --rm phylum-ci:from-dist phylum-ci --version
docker run --rm phylum-ci:from-dist phylum-ci --help
docker run --rm phylum-ci:from-dist phylum-init --help
docker run --rm phylum-ci:from-dist phylum --help
# This job reports the results of the test jobs above and is used to enforce status checks in
# the repo settings without needing to update those settings everytime the test jobs are updated.
test-rollup:
name: Test rollup
runs-on: ubuntu-latest
if: always()
needs: [QA, test-matrix, docker]
steps:
- name: Check for test jobs failure
if: >
(needs.QA.result != 'success')
|| (needs.test-matrix.result != 'success')
|| (needs.docker.result != 'success')
run: |
echo "At least one test job was not successful"
exit 1
- name: Confirm test jobs success
if: >
(needs.QA.result == 'success')
&& (needs.test-matrix.result == 'success')
&& (needs.docker.result == 'success')
run: echo "All test jobs were successful"