Skip to content

Commit

Permalink
Merge branch 'ci/49/implement-tests'
Browse files Browse the repository at this point in the history
Signed-off-by: Bryant Finney <bryant.finney@outlook.com>
  • Loading branch information
bryant-finney committed Dec 23, 2023
2 parents 4669c65 + 550b00d commit 1d63f21
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 20 deletions.
36 changes: 36 additions & 0 deletions .github/actions/poe-test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: 🧪 poe test
description: Invoke 'poe test' to run tests for the package.

inputs:
comment_mode:
default: always
description: Passed directly to EnricoMi/publish-unit-test-result-action

title:
default: Test Results
description: Passed directly to EnricoMi/publish-unit-test-result-action

runs:
steps:
- run: poetry install
shell: bash

- run: poe test
shell: bash

- if: always()
uses: actions/upload-artifact@v4
with:
name: Coverage Report
path: docs/reports/pytest-html

- if: always()
uses: EnricoMi/publish-unit-test-result-action@v2
with:
action_fail_on_inconclusive: true
check_name: ${{ inputs.title }}
comment_mode: ${{ inputs.comment_mode }}
fail_on: errors
files: docs/reports/pytest.xml

using: composite
39 changes: 28 additions & 11 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: 🐳 Docker

# run this workflow for...
# - each push to `main`
# - each release tag (starting with `v`)
# - each pull request that changes a relevant file
on:
push:
tags: v*
branches:
- main

pull_request:
paths:
- .github/workflows/docker-build.yml
Expand All @@ -23,6 +14,10 @@ on:
- platforms.yml
- poetry.lock

push:
tags: v*
branches: [main]

# ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

jobs:
Expand All @@ -33,8 +28,8 @@ jobs:
CI_REGISTRY_IMAGE: ghcr.io/${{ github.repository }}
PYTHON_VERSION: "3.11"

permissions:
packages: write
outputs:
version: ${{ steps.meta.outputs.version }}

runs-on: ubuntu-latest

Expand Down Expand Up @@ -115,3 +110,25 @@ jobs:
pull: true
push: true
targets: dev

test:
container:
image: ghcr.io/${{ github.repository }}/dev:${{ needs.build-and-push.outputs.version }}

needs: build-and-push

permissions:
checks: write
contents: read
issues: read
packages: read
pull-requests: write

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/poe-test
with:
title: "Test Results (image: ${{ needs.build-and-push.outputs.version }})"
67 changes: 67 additions & 0 deletions .github/workflows/poe-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: 🧪 poe test

on:
pull_request:
paths:
- "**/*.py"
- "*.py"
- .github/workflows/poe-test.yml
- pyproject.toml
- sample-config.yml

jobs:
check:
env:
GH_TOKEN: ${{ github.token }}

outputs:
triggered_docker: ${{ steps.changes.outputs.match }}

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: gh pr diff
--name-only ${{ github.event.pull_request.number }}
--repo ${{ github.repository }} | sort >changes.txt

cat changes.txt

- run:
yq -r '.on.pull_request.paths[]' .github/workflows/docker-build.yml |
sort | uniq >docker.txt

cat docker.txt

- run: comm -12 changes.txt docker.txt >intersection.txt

cat intersection.txt

- id: changes
run: |
{
echo 'match<<EOF'
cat intersection.txt
echo EOF
} >>"$GITHUB_OUTPUT"
run:
container:
image: ghcr.io/${{ github.repository }}/dev:main

needs: check

permissions:
checks: write
contents: read
issues: read
packages: read
pull-requests: write

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/poe-test
with:
comment_mode: ${{ needs.check.outputs.triggered_docker == '' && 'always' || 'off' }}
title: "Test Results (image: main)"
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ repos:
- flake8-pytest-style
- flake8-tidy-imports
- radon[toml]
- setuptools

- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
Expand Down
18 changes: 9 additions & 9 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ gitpython = ">=3.1.32" # https://nvd.nist.gov/vuln/detail/CVE-2023-4
python-semantic-release = "^8.0.8"
radon = {extras = ["toml"], version = "^6.0.1"}
lxml = {version = ">=4.9.3", python = ">=3.12"}
setuptools = "^69.0.3" # needed by flake8-logging-format

[tool.poetry.group.pre-commit.dependencies]
# note: these must be synchronized with `.pre-commit-config.yaml`
Expand Down

0 comments on commit 1d63f21

Please sign in to comment.