-
Notifications
You must be signed in to change notification settings - Fork 1
178 lines (152 loc) · 5.97 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
# 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
env:
PYTHON_VERSION: "3.12"
POETRY_VERSION: "1.8.5"
jobs:
QA:
name: Quality Assurance
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install poetry
run: pipx install poetry==${{ env.POETRY_VERSION }}
- name: Configure poetry
run: poetry config virtualenvs.in-project true
- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'poetry'
- name: Install the project with poetry
run: |
poetry env use python${{ env.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.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout the repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install poetry
run: pipx install poetry==${{ env.POETRY_VERSION }}
- name: Configure poetry
run: poetry config virtualenvs.in-project true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.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 with various Dockerfiles, from source or a built distribution, and
# have the script entry points called without error.
docker-matrix:
name: ${{ matrix.dockerfile }} ${{ matrix.build }} smoke test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
dockerfile: ["Dockerfile", "Dockerfile.slim"]
build: ["wheel", "source"]
env:
DOCKER_BUILDKIT: 1
steps:
- name: Checkout the repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install poetry
if: ${{ matrix.build == 'wheel' }}
run: pipx install poetry==${{ env.POETRY_VERSION }}
- name: Configure poetry
if: ${{ matrix.build == 'wheel' }}
run: poetry config virtualenvs.in-project true
- name: Set up Python
if: ${{ matrix.build == 'wheel' }}
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'poetry'
- name: Install the project with poetry
if: ${{ matrix.build == 'wheel' }}
run: |
poetry env use python${{ env.PYTHON_VERSION }}
poetry check --lock
poetry lock --no-update --no-cache
poetry install --verbose --no-root --sync
- name: Build wheel and source distribution
if: ${{ matrix.build == 'wheel' }}
run: poetry build -vvv
- name: Build docker image with pre-built distributions
if: ${{ matrix.build == 'wheel' }}
run: |
docker build \
--tag phylum-ci \
--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 }} \
--file ${{ matrix.dockerfile }} \
.
- name: Build docker image from source
if: ${{ matrix.build == 'source' }}
run: |
docker build \
--tag phylum-ci \
--cache-from phylumio/phylum-ci:latest \
--build-arg GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
--file ${{ matrix.dockerfile }} \
.
- name: Test slim docker image built from ${{ matrix.build }}
if: ${{ matrix.dockerfile == 'Dockerfile.slim' }}
run: scripts/docker_tests.sh --image phylum-ci --slim
- name: Test full docker image built from ${{ matrix.build }}
if: ${{ matrix.dockerfile == 'Dockerfile' }}
run: scripts/docker_tests.sh --image phylum-ci
# 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-matrix]
steps:
- name: Check for test jobs failure or cancellation
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1