Skip to content

Commit

Permalink
split out static analysis from the test matrix
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Goodman <[email protected]>
  • Loading branch information
wagoodman committed Nov 8, 2023
1 parent cca129f commit 0c5a350
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 22 deletions.
4 changes: 3 additions & 1 deletion .github/actions/bootstrap/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ inputs:
python-version:
description: "Python version to install"
required: true
default: "3.9" # note: the caller really drives this in a matrix strategy run
# note: the caller really drives this in a matrix strategy run for unit tests.
# this default value is used for the rest of the workflow.
default: "3.11"
poetry-version:
description: "Poetry version to install"
required: true
Expand Down
20 changes: 15 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,22 @@ jobs:
git fetch origin main
git merge-base --is-ancestor ${GITHUB_REF##*/} origin/main && echo "${GITHUB_REF##*/} is a commit on main!"
- name: Check validation results
- name: Check static analysis results
uses: fountainhead/action-wait-for-check@297be350cf8393728ea4d4b39435c7d7ae167c93 #v1.1.1
id: validations
id: static-analysis
with:
token: ${{ secrets.GITHUB_TOKEN }}
# This check name is defined as the github action job name (in .github/workflows/validations.yaml)
checkName: "Validations"
checkName: "Static Analysis"
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Check test results
uses: fountainhead/action-wait-for-check@297be350cf8393728ea4d4b39435c7d7ae167c93 #v1.1.1
id: test
with:
token: ${{ secrets.GITHUB_TOKEN }}
# This check name is defined as the github action job name (in .github/workflows/validations.yaml)
checkName: "Test"
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Check nightly quality gate results
Expand All @@ -50,9 +59,10 @@ jobs:
intervalSeconds: 3

- name: Release quality gate
if: steps.validations.conclusion != 'success' || steps.nightly-quality-gate.conclusion != 'success'
if: steps.static-analysis.conclusion != 'success' || steps.test.conclusion != 'success' || steps.nightly-quality-gate.conclusion != 'success'
run: |
echo "Validations Status: ${{ steps.validations.conclusion }}"
echo "Static Analysis Status: ${{ steps.static-analysis.conclusion }}"
echo "Test Status: ${{ steps.test.conclusion }}"
echo "Nightly Quality Gate Status: ${{ steps.nightly-quality-gate.conclusion }}"
false
Expand Down
35 changes: 25 additions & 10 deletions .github/workflows/validations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ on:
jobs:

# note: the name for this check is referenced in release.yaml, do not change here without changing there
Validations:
Static-Analysis:
name: "Static Analysis"
runs-on: ubuntu-22.04
permissions:
contents: read
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
Expand All @@ -26,25 +24,42 @@ jobs:

- name: Bootstrap environment
uses: ./.github/actions/bootstrap
with:
python-version: ${{ matrix.python-version }}

- name: Run static analysis
run: poetry run make static-analysis

- name: Run unit tests
run: poetry run make unit

- name: Ensure quality gate tools are properly configured
run: |
cd tests/quality && make validate-test-tool-versions
Test:
runs-on: ubuntu-22.04
permissions:
contents: read
strategy:
matrix:
# note: this is not a single source of truth (this is also in the tox.ini)
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
# in order to properly resolve the version from git
fetch-depth: 0

- name: Bootstrap environment
uses: ./.github/actions/bootstrap
with:
python-version: ${{ matrix.python-version }}

- name: Run unit tests
run: poetry run make unit-matrix

- name: Build assets
run: poetry run make build

Publish-PreProd:
runs-on: ubuntu-22.04
needs: [Validations]
needs: [Static-Analysis, Test]
if: github.ref == 'refs/heads/main'
permissions:
contents: read
Expand Down
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
addopts = -vv --color=yes
2 changes: 1 addition & 1 deletion src/vunnel/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class State(DataClassDictMixin):
store: str
timestamp: datetime.datetime
version: int = 1
listing: Optional[File] = None # why use Optional? mashumaro does not support this on python 3.9
listing: Optional[File] = None # noqa:UP007 # why use Optional? mashumaro does not support this on python 3.9
schema: schemaDef.Schema = field(default_factory=schemaDef.ProviderStateSchema)

@staticmethod
Expand Down
4 changes: 3 additions & 1 deletion tests/quality/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
GRYPE_DB = f"{BIN_DIR}/grype-db"


class Application(YardstickApplication, DataClassDictMixin): pass
class Application(YardstickApplication, DataClassDictMixin):
pass


@dataclass
class ConfigurationState(DataClassDictMixin):
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/cli/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def test_full_config(helpers):
# this is what we added in the config
42: "https://alas.aws.amazon.com/AL2/alas-42.rss",
# this is the defaults...
2: 'https://alas.aws.amazon.com/AL2/alas.rss',
2022: 'https://alas.aws.amazon.com/AL2022/alas.rss',
2023: 'https://alas.aws.amazon.com/AL2023/alas.rss'
2: "https://alas.aws.amazon.com/AL2/alas.rss",
2022: "https://alas.aws.amazon.com/AL2022/alas.rss",
2023: "https://alas.aws.amazon.com/AL2023/alas.rss",
},
runtime=runtime_cfg,
request_timeout=20,
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[tox]
# note: this is not a single source of truth (this is also in the .github/workflows/valiations.yml file)
envlist = py39, py310, py311, py312

# https://github.com/ymyzk/tox-gh-actions
Expand All @@ -16,4 +17,3 @@ skip_install = true
commands =
poetry install -vvv
poetry run pytest --cov-report html --cov vunnel -v tests/unit/

0 comments on commit 0c5a350

Please sign in to comment.