Skip to content

Commit

Permalink
Change: Use generic reusable workflows
Browse files Browse the repository at this point in the history
Use our new generic reusable workflows where possible.
  • Loading branch information
bjoernricks committed May 17, 2023
1 parent afed628 commit a0e8d09
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 114 deletions.
72 changes: 11 additions & 61 deletions .github/workflows/ci-python.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
name: Build and test Python package
name: Check and test Python project

on:
push:
branches: [main]
branches:
- main
pull_request:
branches: [main]

jobs:
linting:
name: Linting
runs-on: "ubuntu-latest"
check-and-test:
name: Check and test
strategy:
matrix:
python-version:
Expand All @@ -18,60 +17,13 @@ jobs:
- "3.9"
- "3.10"
- "3.11"
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: greenbone/actions/lint-python@v2
with:
packages: autohooks tests
python-version: ${{ matrix.python-version }}
cache: "true"

type-check:
name: Type-check
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.11"
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: greenbone/actions/mypy-python@v2
with:
packages: autohooks
python-version: ${{ matrix.python-version }}
cache: "true"

test:
name: Run all tests
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
steps:
- uses: actions/checkout@v3
- name: Install poetry and dependencies
uses: greenbone/actions/poetry@v2
with:
python-version: ${{ matrix.python-version }}
cache: "true"
- name: Run unit tests
run: poetry run python -m unittest -v
uses: greenbone/workflows/.github/workflows/ci-python.yml@main
with:
lint-packages: autohooks tests
python-version: ${{ matrix.python-version }}

codecov:
name: Upload coverage to codecov.io
needs: test
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v3
Expand All @@ -80,10 +32,8 @@ jobs:
with:
python-version: "3.10"
cache: "true"
token: ${{ secrets.CODECOV_TOKEN }}

check-version:
name: Check versioning for consistency
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v3
- uses: greenbone/actions/check-version@v2
uses: greenbone/workflows/.github/workflows/check-version.yml@main
8 changes: 2 additions & 6 deletions .github/workflows/deploy-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@ on:

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Build and publish to PyPI
uses: greenbone/actions/pypi-upload@v2
with:
pypi-token: ${{ secrets.PYPI_TOKEN }}
uses: greenbone/workflows/.github/workflows/deploy-pypi.yml@main
secrets: inherit
23 changes: 1 addition & 22 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,4 @@ concurrency:

jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install poetry and dependencies
uses: greenbone/actions/poetry@v2
with:
python-version: "3.10"
cache: "true"
- name: Build Documentation
run: |
cd docs && poetry run make html
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: "docs/build/html"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: greenbone/workflows/.github/workflows/docs-python.yml@main
29 changes: 4 additions & 25 deletions .github/workflows/release-pontos.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release Python package with pontos
name: Release Python package

on:
pull_request:
Expand All @@ -7,27 +7,6 @@ on:

jobs:
build-and-release:
name: Create a new release with pontos
# If the event is a workflow_dispatch or the label 'make release' is set and PR is closed because of a merge
if: (github.event_name == 'workflow_dispatch') || (contains( github.event.pull_request.labels.*.name, 'make release') && github.event.pull_request.merged == true)
runs-on: "ubuntu-latest"
steps:
- name: Setting the Reference
run: |
if [[ "${{ github.event_name }}" = "workflow_dispatch" ]]; then
echo "RELEASE_REF=${{ github.ref_name }}" >> $GITHUB_ENV
else
echo "RELEASE_REF=${{ github.base_ref }}" >> $GITHUB_ENV
fi
- name: Release with release action
uses: greenbone/actions/release@v2
with:
conventional-commits: true
github-user: ${{ secrets.GREENBONE_BOT }}
github-user-mail: ${{ secrets.GREENBONE_BOT_MAIL }}
github-user-token: ${{ secrets.GREENBONE_BOT_TOKEN }}
gpg-key: ${{ secrets.GPG_KEY }}
gpg-fingerprint: ${{ secrets.GPG_FINGERPRINT }}
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
strategy: calendar
ref: ${{ env.RELEASE_REF }}
name: Create a new release
uses: greenbone/workflows/.github/workflows/release-python.yml@main
secrets: inherit
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,6 @@ profile = "black"
line_length = 80

[tool.mypy]
files = "autohooks"
ignore_missing_imports = true
explicit_package_bases = true

0 comments on commit a0e8d09

Please sign in to comment.