Skip to content

Commit a5cc2c9

Browse files
author
Dale Myers
committed
Use GitHub actions for testing
1 parent 39259f3 commit a5cc2c9

File tree

6 files changed

+376
-112
lines changed

6 files changed

+376
-112
lines changed

.azure/azure-pipelines.yml

Lines changed: 0 additions & 62 deletions
This file was deleted.

.azure/publish.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, master, develop ]
6+
pull_request:
7+
branches: [ main, master, develop ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
name: Test Python ${{ matrix.python-version }}
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: Install Poetry
29+
uses: snok/install-poetry@v1
30+
with:
31+
version: latest
32+
virtualenvs-create: true
33+
virtualenvs-in-project: true
34+
35+
- name: Load cached venv
36+
id: cached-poetry-dependencies
37+
uses: actions/cache@v4
38+
with:
39+
path: .venv
40+
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
41+
42+
- name: Install dependencies
43+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
44+
run: poetry install --no-interaction --no-root
45+
46+
- name: Install project
47+
run: poetry install --no-interaction
48+
49+
- name: Run black check
50+
run: poetry run black --check --line-length 100 simple_ado tests
51+
52+
- name: Run pylint
53+
run: |
54+
poetry run pylint --rcfile=pylintrc simple_ado
55+
poetry run pylint --rcfile=pylintrc tests
56+
57+
- name: Run mypy
58+
run: |
59+
poetry run mypy --ignore-missing-imports simple_ado/
60+
poetry run mypy --ignore-missing-imports tests/
61+
62+
- name: Run unit tests
63+
run: poetry run pytest tests/unit/ --cov=simple_ado --cov-report=xml --cov-report=html --junitxml=junit/test-results.xml
64+
65+
- name: Upload coverage to Codecov
66+
uses: codecov/codecov-action@v4
67+
if: matrix.python-version == '3.12'
68+
with:
69+
file: ./coverage.xml
70+
fail_ci_if_error: false
71+
token: ${{ secrets.CODECOV_TOKEN }}
72+
73+
- name: Upload test results
74+
uses: actions/upload-artifact@v4
75+
if: always()
76+
with:
77+
name: test-results-${{ matrix.python-version }}
78+
path: junit/test-results.xml
79+
80+
- name: Upload coverage HTML report
81+
uses: actions/upload-artifact@v4
82+
if: always()
83+
with:
84+
name: coverage-html-${{ matrix.python-version }}
85+
path: htmlcov/
86+
87+
- name: Upload coverage to Codecov
88+
uses: codecov/codecov-action@v4
89+
if: always()
90+
with:
91+
file: ./coverage.xml
92+
flags: unittests
93+
name: codecov-umbrella
94+
fail_ci_if_error: false
95+
96+
deploy-coverage:
97+
name: Deploy Coverage to GitHub Pages
98+
needs: test
99+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
100+
runs-on: ubuntu-latest
101+
102+
permissions:
103+
pages: write
104+
id-token: write
105+
106+
environment:
107+
name: github-pages
108+
url: ${{ steps.deployment.outputs.page_url }}
109+
110+
steps:
111+
- name: Download all coverage HTML reports
112+
uses: actions/download-artifact@v4
113+
with:
114+
pattern: coverage-html-*
115+
path: coverage-artifacts
116+
117+
- name: Select latest Python version coverage
118+
run: |
119+
# Find the coverage report from the highest Python version
120+
LATEST_DIR=$(ls -d coverage-artifacts/coverage-html-* | sort -V | tail -1)
121+
echo "Using coverage from: $LATEST_DIR"
122+
mv "$LATEST_DIR" htmlcov
123+
124+
- name: Upload Pages artifact
125+
uses: actions/upload-pages-artifact@v3
126+
with:
127+
path: htmlcov
128+
129+
- name: Deploy to GitHub Pages
130+
id: deployment
131+
uses: actions/deploy-pages@v4
132+
133+
integration-tests:
134+
name: Integration Tests
135+
runs-on: ubuntu-latest
136+
# Only run if ADO credentials are available
137+
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
138+
139+
steps:
140+
- name: Checkout code
141+
uses: actions/checkout@v4
142+
143+
- name: Set up Python
144+
uses: actions/setup-python@v5
145+
with:
146+
python-version: "3.12"
147+
148+
- name: Install Poetry
149+
uses: snok/install-poetry@v1
150+
with:
151+
version: latest
152+
virtualenvs-create: true
153+
virtualenvs-in-project: true
154+
155+
- name: Install dependencies
156+
run: poetry install --no-interaction
157+
158+
- name: Run integration tests
159+
run: poetry run pytest tests/ --integration --junitxml=junit/integration-results.xml
160+
env:
161+
SIMPLE_ADO_BASE_TOKEN: ${{ secrets.SIMPLE_ADO_BASE_TOKEN }}
162+
SIMPLE_ADO_TENANT: ${{ secrets.SIMPLE_ADO_TENANT }}
163+
SIMPLE_ADO_PROJECT_ID: ${{ secrets.SIMPLE_ADO_PROJECT_ID }}
164+
SIMPLE_ADO_REPO_ID: ${{ secrets.SIMPLE_ADO_REPO_ID }}
165+
166+
- name: Upload integration test results
167+
uses: actions/upload-artifact@v4
168+
if: always()
169+
with:
170+
name: integration-test-results
171+
path: junit/integration-results.xml

.github/workflows/publish.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
publish:
9+
description: 'Publish to PyPI'
10+
required: true
11+
type: boolean
12+
default: false
13+
14+
jobs:
15+
build:
16+
name: Build distribution
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.x"
27+
28+
- name: Install Poetry
29+
uses: snok/install-poetry@v1
30+
with:
31+
version: latest
32+
33+
- name: Install dependencies
34+
run: poetry install --no-interaction
35+
36+
- name: Build package
37+
run: poetry build
38+
39+
- name: Store the distribution packages
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: python-package-distributions
43+
path: dist/
44+
45+
publish-to-pypi:
46+
name: Publish to PyPI
47+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.publish == 'true')
48+
needs:
49+
- build
50+
runs-on: ubuntu-latest
51+
environment:
52+
name: pypi
53+
url: https://pypi.org/p/simple-ado
54+
permissions:
55+
id-token: write # IMPORTANT: mandatory for trusted publishing
56+
57+
steps:
58+
- name: Download all the dists
59+
uses: actions/download-artifact@v4
60+
with:
61+
name: python-package-distributions
62+
path: dist/
63+
64+
- name: Publish distribution to PyPI
65+
uses: pypa/gh-action-pypi-publish@release/v1
66+
67+
publish-to-testpypi:
68+
name: Publish to TestPyPI
69+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.publish != 'true'
70+
needs:
71+
- build
72+
runs-on: ubuntu-latest
73+
environment:
74+
name: testpypi
75+
url: https://test.pypi.org/p/simple-ado
76+
permissions:
77+
id-token: write # IMPORTANT: mandatory for trusted publishing
78+
79+
steps:
80+
- name: Download all the dists
81+
uses: actions/download-artifact@v4
82+
with:
83+
name: python-package-distributions
84+
path: dist/
85+
86+
- name: Publish distribution to TestPyPI
87+
uses: pypa/gh-action-pypi-publish@release/v1
88+
with:
89+
repository-url: https://test.pypi.org/legacy/
90+
91+
github-release:
92+
name: Create GitHub Release
93+
if: github.event_name == 'release'
94+
needs:
95+
- publish-to-pypi
96+
runs-on: ubuntu-latest
97+
permissions:
98+
contents: write # IMPORTANT: mandatory for creating releases
99+
id-token: write # IMPORTANT: mandatory for sigstore
100+
101+
steps:
102+
- name: Download all the dists
103+
uses: actions/download-artifact@v4
104+
with:
105+
name: python-package-distributions
106+
path: dist/
107+
108+
- name: Sign the dists with Sigstore
109+
uses: sigstore/[email protected]
110+
with:
111+
inputs: >-
112+
./dist/*.tar.gz
113+
./dist/*.whl
114+
115+
- name: Upload artifact signatures to GitHub Release
116+
env:
117+
GITHUB_TOKEN: ${{ github.token }}
118+
# Upload to GitHub Release using the `gh` CLI.
119+
run: >-
120+
gh release upload
121+
'${{ github.ref_name }}' dist/**
122+
--repo '${{ github.repository }}'

0 commit comments

Comments
 (0)