Skip to content
This repository was archived by the owner on May 7, 2026. It is now read-only.

chore(ci): Update and Pin GH Actions #120

chore(ci): Update and Pin GH Actions

chore(ci): Update and Pin GH Actions #120

Workflow file for this run

#
# Copyright 2022-Present Sonatype Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# For details of what checks are run for PRs please refer below
# docs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
name: Python CI
on:
push:
branches: ["main"]
pull_request:
workflow_dispatch:
schedule:
# schedule weekly tests, since dependencies are not intended to be pinned
# this means: at 23:42 on Fridays
- cron: '42 23 * * 5'
env:
REPORTS_DIR: CI_reports
PYTHON_VERSION_DEFAULT: "3.10"
POETRY_VERSION: "1.1.11"
jobs:
coding-standards:
name: Linting & CodingStandards
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
architecture: 'x64'
- name: Install poetry
uses: Gr1N/setup-poetry@48b0f77c8c1b1b19cb962f0f00dff7b4be8f81ec # v9
with:
poetry-version: ${{ env.POETRY_VERSION }}
- name: Install dependencies
run: poetry install --no-root
- name: Run tox
run: poetry run tox -e flake8
static-code-analysis:
name: StaticCodingAnalysis (py${{ matrix.python-version}} ${{ matrix.toxenv-factor }})
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- # test with the locked dependencies
python-version: '3.10'
toxenv-factor: 'locked'
- # test with the lowest dependencies
python-version: '3.6'
toxenv-factor: 'lowest'
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
architecture: 'x64'
- name: Install poetry
uses: Gr1N/setup-poetry@48b0f77c8c1b1b19cb962f0f00dff7b4be8f81ec # v9
with:
poetry-version: ${{ env.POETRY_VERSION }}
- name: Install dependencies
run: poetry install --no-root
- name: Run tox
run: poetry run tox -e mypy-${{ matrix.toxenv-factor }}
build-and-test:
name: Test (${{ matrix.os }} py${{ matrix.python-version }} ${{ matrix.toxenv-factor }})
runs-on: ${{ matrix.os }}
env:
REPORTS_ARTIFACT: tests-reports
strategy:
fail-fast: false
matrix:
os: ['ubuntu-20.04', 'windows-latest', 'macos-latest']
python-version:
- "3.10" # highest supported
- "3.9"
- "3.8"
- "3.7"
- "3.6" # lowest supported
toxenv-factor: ['locked']
include:
- # test with the lowest dependencies
os: 'ubuntu-20.04'
python-version: '3.6'
toxenv: 'lowest'
timeout-minutes: 30
steps:
- name: Disabled Git auto EOL CRLF transforms
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Create reports directory
run: mkdir ${{ env.REPORTS_DIR }}
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
architecture: 'x64'
- name: Install poetry
uses: Gr1N/setup-poetry@48b0f77c8c1b1b19cb962f0f00dff7b4be8f81ec # v9
with:
poetry-version: ${{ env.POETRY_VERSION }}
- name: Install dependencies
run: poetry install --no-root
- name: Ensure build successful
run: poetry build
- name: Run tox
run: poetry run tox -e py-${{ matrix.toxenv-factor }} -s false
- name: Generate coverage reports
run: >
poetry run coverage report &&
poetry run coverage xml -o ${{ env.REPORTS_DIR }}/coverage-${{ matrix.os }}-${{ matrix.python-version }}.xml &&
poetry run coverage html -d ${{ env.REPORTS_DIR }}
- name: Artifact reports
if: ${{ ! cancelled() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ env.REPORTS_ARTIFACT }}
path: ${{ env.REPORTS_DIR }}
if-no-files-found: error