Skip to content

Commit

Permalink
Implements #164
Browse files Browse the repository at this point in the history
  • Loading branch information
vduseev committed Feb 22, 2024
1 parent 769ca07 commit 433bdec
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 71 deletions.
Original file line number Diff line number Diff line change
@@ -1,74 +1,21 @@
name: Build Test Release
name: Release
on:
pull_request:
branches:
- main
push:
# this works as an OR
branches:
- main
tags:
- "v*"
workflow_dispatch:

jobs:
check-line-endings:
name: Check CRLF line endings
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Checkout repository contents
uses: actions/checkout@v4

- name: Use action to check for CRLF endings
uses: erclu/check-crlf@v1

run-tests:
name: Run tests
runs-on: ubuntu-latest
timeout-minutes: 5
needs: check-line-endings
steps:
- name: Checkout repository contents
uses: actions/checkout@v4

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install poetry
run: |
pip install poetry
poetry install
- name: Run pytest tests
run: |
poetry run pytest
# Disabled by vduseev on 2024-02-21
# because it's clear we are not using mypy here
#- name: Run mypy tests
# run: |
# bash -c '! poetry run mypy --strict dtcli | grep "Module has no attribute"'

- name: Run flake8 lint checker
run: |
poetry run flake8 dtcli
- name: Run test coverage report
run: |
poetry run pytest --cov . --cov-report html || true
build-package:
name: Build package
#
# Builds python package using poetry.
#
runs-on: ubuntu-latest
timeout-minutes: 5
needs: run-tests
steps:
- id: check_ref
run: echo "::set-output name=match::$(echo '${{ github.ref }}' | grep -Pq '^refs/tags/v\d+\.\d+\.\d+$' && echo true || echo false)"
shell: bash

- name: Check if tag is valid
if: steps.check_ref.outputs.match != 'true'
run: exit 1

- name: Checkout repository contents
uses: actions/checkout@v4

Expand All @@ -95,17 +42,12 @@ jobs:
github-release:
name: Create GitHub release
#
# Creates GitHub release with binaries and packages.
#
# Only happens for tags.
#
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs:
- build-package
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Generate changelog
run: |
Expand Down Expand Up @@ -138,11 +80,10 @@ jobs:

publish-to-pypi:
name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs:
- build-package
- run-tests
steps:
- uses: actions/checkout@v4

Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Test
on:
pull_request:
push:
workflow_dispatch:

jobs:
check-line-endings:
name: Check CRLF line endings
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Checkout repository contents
uses: actions/checkout@v4

- name: Use action to check for CRLF endings
uses: erclu/check-crlf@v1

run-tests:
name: Run tests
strategy:
fail-fast: true
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
os: [ubuntu-latest, windows-latest, macos-latest]

runs-on: ${{ matrix.os }}
timeout-minutes: 5
needs: check-line-endings
steps:
- name: Checkout repository contents
uses: actions/checkout@v4

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
run: |
pip install poetry
poetry install
- name: Run pytest tests
run: |
poetry run pytest
# Disabled by vduseev on 2024-02-21
# because it's clear we are not using mypy here
#- name: Run mypy tests
# run: |
# bash -c '! poetry run mypy --strict dtcli | grep "Module has no attribute"'

- name: Run flake8 lint checker
run: |
poetry run flake8 dtcli
- name: Run test coverage report
run: |
poetry run pytest --cov . --cov-report html || true
- name: Check that the package can be built
run: |
poetry build
- name: Check that we can generate a CA certificate
run: |
poetry run dt ext genca --ca-cert ./ca.pem --ca-key ./ca.key --ca-subject "/CN=Default/O=Company/OU=Extension" --no-ca-passphrase --force

0 comments on commit 433bdec

Please sign in to comment.