Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build-image-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
persist-credentials: false

- name: Get changed Docker related files
id: changed-files-specific
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
- name: Login to GitHub Container Registry
Expand All @@ -30,10 +33,13 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set tag for image
env:
REF_TYPE: ${{ github.ref_type }}
REF_NAME: ${{ github.ref_name }}
run: >-
echo IMAGE_TAG=$(
[ ${{ github.ref_type }} == 'tag' ]
&& echo ${{ github.ref_name }}
[ $REF_TYPE == 'tag' ]
&& echo $REF_NAME
|| echo 'latest'
) >> $GITHUB_ENV

Expand Down
37 changes: 16 additions & 21 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
persist-credentials: false
- name: >-
Calculate Python interpreter version hash value
for use in the cache key
Expand Down Expand Up @@ -208,6 +209,8 @@ jobs:
)
- name: Set the target Git tag
id: git-tag
env:
DIST_VERSION: ${{ steps.scm-version.outputs.dist-version }}
run: |
from os import environ
from pathlib import Path
Expand All @@ -218,13 +221,13 @@ jobs:
mode=FILE_APPEND_MODE,
) as outputs_file:
print(
"tag=v${{
steps.scm-version.outputs.dist-version
}}",
f"tag=v{environ['DIST_VERSION'].removeprefix('v')}",
file=outputs_file,
)
- name: Set the expected dist artifact names
id: artifact-name
env:
DIST_VERSION: ${{ steps.scm-version.outputs.dist-version }}
run: |
from os import environ
from pathlib import Path
Expand All @@ -238,15 +241,11 @@ jobs:
mode=FILE_APPEND_MODE,
) as outputs_file:
print(
f"sdist={sdist_file_prj_base_name !s}-${{
steps.scm-version.outputs.dist-version
}}.tar.gz",
f"sdist={sdist_file_prj_base_name !s}-{environ['DIST_VERSION']}.tar.gz",
file=outputs_file,
)
print(
f"wheel={whl_file_prj_base_name !s}-${{
steps.scm-version.outputs.dist-version
}}-py3-none-any.whl",
f"wheel={whl_file_prj_base_name !s}-{environ['DIST_VERSION']}-py3-none-any.whl",
file=outputs_file,
)

Expand All @@ -268,7 +267,8 @@ jobs:

env:
TOXENV: cleanup-dists,build-dists

SDIST_ARTIFACT_NAME: ${{ needs.pre-setup.outputs.sdist-artifact-name }}
WHEEL_ARTIFACT_NAME: ${{ needs.pre-setup.outputs.wheel-artifact-name }}
outputs:
dists-base64-hash: ${{ steps.dist-hashes.outputs.combined-hash }}

Expand All @@ -282,6 +282,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
persist-credentials: false

- name: >-
Calculate Python interpreter version hash value
Expand Down Expand Up @@ -357,19 +358,13 @@ jobs:
--quiet
- name: Verify that the artifacts with expected names got created
run: >-
ls -1
'dist/${{ needs.pre-setup.outputs.sdist-artifact-name }}'
'dist/${{ needs.pre-setup.outputs.wheel-artifact-name }}'
ls -1 "dist/${SDIST_ARTIFACT_NAME}" "dist/${WHEEL_ARTIFACT_NAME}"
- name: Generate dist hashes to be used for provenance
id: dist-hashes
run: >-
echo "combined-hash=$(
sha256sum
'${{ needs.pre-setup.outputs.sdist-artifact-name }}'
'${{ needs.pre-setup.outputs.wheel-artifact-name }}'
| base64 -w0
)"
>> "${GITHUB_OUTPUT}"
sha256sum "$SDIST_ARTIFACT_NAME" "$WHEEL_ARTIFACT_NAME" | base64 -w0
)" >> $GITHUB_OUTPUT
working-directory: dist
- name: Store the distribution packages
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
Expand All @@ -386,7 +381,7 @@ jobs:
retention-days: 30

lint:
name: 🧹 Linters${{ '' }} # nest jobs under the same sidebar category
name: 🧹 Linters${{ '' }} # Group jobs in sidebar # zizmor: ignore[obfuscation]
needs:
- build
- pre-setup # transitive, for accessing settings
Expand Down Expand Up @@ -444,7 +439,7 @@ jobs:
codecov-token: ${{ secrets.CODECOV_TOKEN }}

tests:
name: 🧪 Tests${{ '' }} # nest jobs under the same sidebar category
name: 🧪 Tests${{ '' }} # Group jobs in sidebar # zizmor: ignore[obfuscation]
needs:
- build
- pre-setup # transitive, for accessing settings
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

- name: Dependency Review
uses: actions/dependency-review-action@da24556b548a50705dd671f47852072ea4c105d9 # v4.7.1
2 changes: 1 addition & 1 deletion .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Validate PR title

on:
pull_request_target:
pull_request:
types:
- opened
- edited
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- run: >-
git fetch --no-tags --prune --depth=1 origin
+refs/heads/*:refs/remotes/origin/*

- name: Get changed files
id: file_changes
env:
BASE_REF: ${{ github.base_ref }}
SHA: ${{ github.sha }}
run: |
export DIFF=$(git diff --name-only origin/${{ github.base_ref }} ${{
github.sha
}})
echo "Diff between ${{ github.base_ref }} and ${{ github.sha }}"
export DIFF=$(git diff --name-only "origin/$BASE_REF" "$SHA")
echo "Diff between $BASE_REF and $SHA"
echo "files=$( echo "$DIFF" | xargs echo )" >> $GITHUB_OUTPUT

- name: Install shfmt
Expand All @@ -48,10 +51,11 @@ jobs:
)"
> hadolint
&& chmod +x hadolint && sudo mv hadolint /usr/bin/
# Needed for pre-commit fix push to succeed
# Needed for pre-commit fix push to succeed
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ github.event.pull_request.head.sha }}
# Needed to trigger pre-commit workflow on autofix commit. Guide:
# https://web.archive.org/web/20210731173012/https://github.community/t/required-check-is-expected-after-automated-push/187545/
Expand Down
73 changes: 44 additions & 29 deletions .github/workflows/reusable-tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,10 @@ jobs:
steps:
- name: Export requested job-global environment variables
if: inputs.environment-variables != ''
env:
INPUT_ENV_VARS: ${{ inputs.environment-variables }}
run: >-
echo '${{ inputs.environment-variables }}'
>> "${GITHUB_ENV}"
echo "$INPUT_ENV_VARS" >> $GITHUB_ENV

- name: >-
Switch to using Python v${{ inputs.python-version }}
Expand All @@ -170,6 +171,7 @@ jobs:
contains(fromJSON('["pre-commit", "spellcheck-docs"]'), inputs.toxenv)
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
ref: ${{ github.event.inputs.release-committish }}
- name: Retrieve the project source from an sdist inside the GHA artifact
if: >-
Expand Down Expand Up @@ -273,18 +275,24 @@ jobs:

- name: >-
Pre-populate tox envs: `${{ env.TOXENV }}`
run: >-
python -Im
tox
--parallel auto
--parallel-live
--skip-missing-interpreters false
${{
inputs.built-wheel-names != ''
&& format('--installpkg dist/{0}', inputs.built-wheel-names)
|| ''
}}
--notest
shell: bash
env:
INPUT_BUILT_WHEEL_NAMES: ${{ inputs.built-wheel-names }}
run: |-
tox_common_args=(
--parallel auto
--parallel-live
--skip-missing-interpreters false
)
if [[ $INPUT_BUILT_WHEEL_NAMES ]]; then
python -Im tox "${tox_common_args[@]}" \
--installpkg "dist/$INPUT_BUILT_WHEEL_NAMES" \
--notest
else
python -Im tox "${tox_common_args[@]}" \
--notest
fi

- name: Initialize pre-commit envs if needed
if: inputs.toxenv == 'pre-commit'
run: >-
Expand All @@ -301,19 +309,24 @@ jobs:
- name: >-
Run tox envs: `${{ env.TOXENV }}`
id: tox-run
run: >-
python -Im
tox
--parallel auto
--parallel-live
--skip-missing-interpreters false
--skip-pkg-install
--quiet
${{
inputs.tox-run-posargs != ''
&& format('-- {0}', inputs.tox-run-posargs)
|| ''
}}
shell: bash
env:
INPUT_TOX_RUN_POSARGS: ${{ inputs.tox-run-posargs }}
run: |-
tox_common_args=(
--parallel auto
--parallel-live
--skip-missing-interpreters false
--skip-pkg-install
--quiet
)
if [ -n "$INPUT_TOX_RUN_POSARGS" ]; then
python -Im tox "${tox_common_args[@]}" \
-- "$INPUT_TOX_RUN_POSARGS"
else
python -Im tox "${tox_common_args[@]}"
fi

# Generate nice SVG image of passed/failed tests in GHA Job Summary
- name: Produce markdown test summary from JUnit
if: >-
Expand Down Expand Up @@ -352,13 +365,15 @@ jobs:
&& steps.tox-run.outputs.test-result-files == ''
&& steps.tox-run.outputs.codecov-flags != 'MyPy'
run: >-
cat code-coverage-results.md >> "${GITHUB_STEP_SUMMARY}"
cat code-coverage-results.md >> "$GITHUB_STEP_SUMMARY"
Comment thread
MaxymVlasov marked this conversation as resolved.
- name: Re-run the failing tests with maximum verbosity
if: >-
!cancelled()
&& failure()
&& inputs.tox-rerun-posargs != ''
# `exit 1` makes sure that the job remains red with flaky runs
env:
INPUT_TOX_RERUN_POSARGS: ${{ inputs.tox-rerun-posargs }}
run: >-
python -Im
tox
Expand All @@ -368,7 +383,7 @@ jobs:
-vvvvv
--skip-pkg-install
--
${{ inputs.tox-rerun-posargs }}
$INPUT_TOX_RERUN_POSARGS
&& exit 1
shell: bash
- name: Send coverage data to Codecov
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/scheduled-runs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ jobs:
main-ci-cd-pipeline:
name: ∞ Main CI/CD pipeline
uses: ./.github/workflows/ci-cd.yml
secrets: inherit
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaxymVlasov FYI, I got a reusable workflow that integrates with GitHub's security reporting interfaces natively: https://github.com/zizmorcore/workflow/blob/3bb5e95068d0f44b6d2f3f7e91379bed1d2f96a8/.github/workflows/reusable-zizmor.yml. If you add it, you'll get inline alerts right inside PRs.

Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ repos:
hooks:
- id: gitleaks

# Github Action static analysis tool
- repo: https://github.com/woodruffw/zizmor-pre-commit
rev: v1.9.0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tag and not commit hash? I thought you tend to trust commits rather than tags 🤔

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to switch out from Renovate to pre-commit-freeze then.

I'll do it as separate PR

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think native pre-commit autoupdate can do the same.

hooks:
- id: zizmor

# Dockerfile
- repo: https://github.com/hadolint/hadolint
rev: v2.13.1-beta
Expand Down
Loading