Skip to content

Commit c71074a

Browse files
authored
Merge pull request #6 from druzsan/feature/use-python-dockerfile
Feature/use python dockerfile
2 parents 91f5fe9 + abdb771 commit c71074a

19 files changed

+958
-250
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
3+
!Dockerfile
4+
!requirements.txt
5+
!main.py

.github/workflows/ci-builtin.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: '🔍 CI (built-in matrix)'
2+
3+
on: push
4+
5+
# This workflow serves for multiple purposes:
6+
# - Action code check
7+
# - Action integration test
8+
# - Advanced usage example (reusable matrix)
9+
10+
jobs:
11+
# Check code formatting
12+
check-format:
13+
name: '🔍 Check Formatting'
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, windows-latest, macos-latest]
17+
python-version: ['3.8', '3.10', '3.12']
18+
runs-on: ${{ matrix.os }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
- run: python -m pip install -IU pip setuptools wheel
25+
- run: pip install -IUr requirements.txt -r requirements-dev.txt
26+
- run: black --check .
27+
# Check code types
28+
typecheck:
29+
name: '🔍 Check Types'
30+
strategy:
31+
matrix:
32+
os: [ubuntu-latest, windows-latest, macos-latest]
33+
python-version: ['3.8', '3.10', '3.12']
34+
runs-on: ${{ matrix.os }}
35+
steps:
36+
- uses: actions/checkout@v4
37+
- uses: actions/setup-python@v5
38+
with:
39+
python-version: ${{ matrix.python-version }}
40+
- run: python -m pip install -IU pip setuptools wheel
41+
- run: pip install -IUr requirements.txt -r requirements-dev.txt
42+
- run: mypy main.py && mypy tests
43+
# Lint code
44+
lint:
45+
name: '🔍 Lint'
46+
strategy:
47+
matrix:
48+
os: [ubuntu-latest, windows-latest, macos-latest]
49+
python-version: ['3.8', '3.10', '3.12']
50+
runs-on: ${{ matrix.os }}
51+
steps:
52+
- uses: actions/checkout@v4
53+
- uses: actions/setup-python@v5
54+
with:
55+
python-version: ${{ matrix.python-version }}
56+
- run: python -m pip install -IU pip setuptools wheel
57+
- run: pip install -IUr requirements.txt -r requirements-dev.txt
58+
- run: ruff check main.py tests

.github/workflows/ci.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: '🔍 CI'
2+
3+
on: push
4+
5+
# This workflow serves for multiple purposes:
6+
# - Action code check
7+
# - Action integration test
8+
# - Advanced usage example (reusable matrix)
9+
10+
jobs:
11+
# Setup matrix
12+
setup-matrix:
13+
name: '🧱 Build Matrix'
14+
runs-on: ubuntu-latest
15+
outputs:
16+
matrix: ${{ steps.setup-matrix.outputs.matrix }}
17+
steps:
18+
- id: setup-matrix
19+
uses: druzsan/setup-matrix@feature/use-python-dockerfile
20+
with:
21+
matrix: |
22+
os: [ubuntu-latest, windows-latest, macos-latest]
23+
python-version: [3.8, 3.10, 3.12]
24+
# Check code formatting
25+
check-format:
26+
name: '🔍 Check Formatting'
27+
needs: setup-matrix
28+
strategy:
29+
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
30+
runs-on: ${{ matrix.os }}
31+
steps:
32+
- uses: actions/checkout@v4
33+
- uses: actions/setup-python@v5
34+
with:
35+
python-version: ${{ matrix.python-version }}
36+
- run: python -m pip install -IU pip setuptools wheel
37+
- run: pip install -IUr requirements.txt -r requirements-dev.txt
38+
- run: black --check .
39+
# Check code types
40+
typecheck:
41+
name: '🔍 Check Types'
42+
needs: setup-matrix
43+
strategy:
44+
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
45+
runs-on: ${{ matrix.os }}
46+
steps:
47+
- uses: actions/checkout@v4
48+
- uses: actions/setup-python@v5
49+
with:
50+
python-version: ${{ matrix.python-version }}
51+
- run: python -m pip install -IU pip setuptools wheel
52+
- run: pip install -IUr requirements.txt -r requirements-dev.txt
53+
- run: mypy main.py && mypy tests
54+
# Lint code
55+
lint:
56+
name: '🔍 Lint'
57+
needs: setup-matrix
58+
strategy:
59+
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
60+
runs-on: ${{ matrix.os }}
61+
steps:
62+
- uses: actions/checkout@v4
63+
- uses: actions/setup-python@v5
64+
with:
65+
python-version: ${{ matrix.python-version }}
66+
- run: python -m pip install -IU pip setuptools wheel
67+
- run: pip install -IUr requirements.txt -r requirements-dev.txt
68+
- run: ruff check main.py tests
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: '🧪 Integration Test'
2+
3+
on:
4+
push:
5+
schedule:
6+
- cron: '0 6 * * *'
7+
workflow_dispatch:
8+
9+
# This workflow serves for multiple purposes:
10+
# - Action integration test
11+
# - Usage example
12+
13+
jobs:
14+
# Valid jobs
15+
setup-matrix-multi-line:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
matrix: ${{ steps.setup-matrix.outputs.matrix }}
19+
steps:
20+
- uses: druzsan/setup-matrix@feature/use-python-dockerfile
21+
with:
22+
matrix: | # Setup matrix with OS and Python version
23+
os: [ubuntu-latest, windows-latest]
24+
python-version: [3.8, 3.10, 3.12]
25+
include:
26+
- os: windows-latest
27+
python-version: 3.8 # Only use Python 3.8 for MacOS
28+
exclude:
29+
- os: windows-latest
30+
python-version: 3.12 # Do not use Python 3.12 for Windows
31+
setup-matrix-flow-syntax:
32+
runs-on: ubuntu-latest
33+
outputs:
34+
matrix: ${{ steps.setup-matrix.outputs.matrix }}
35+
steps:
36+
- uses: druzsan/setup-matrix@feature/use-python-dockerfile
37+
with:
38+
matrix: '{ os: [ubuntu-latest, windows-latest], python-version: [3.8, 3.10, 3.12] }'
39+
# Jobs expected to fail
40+
setup-matrix-empty:
41+
runs-on: ubuntu-latest
42+
outputs:
43+
matrix: ${{ steps.setup-matrix.outputs.matrix }}
44+
steps:
45+
- id: expected-to-fail
46+
uses: druzsan/setup-matrix@feature/use-python-dockerfile
47+
continue-on-error: true
48+
- if: steps.expected-to-fail.outcome != 'failure'
49+
run: echo "Step expected to fail didn't fail" && exit 1
50+
setup-matrix-windows:
51+
runs-on: windows-latest
52+
steps:
53+
- id: expected-to-fail
54+
uses: druzsan/setup-matrix@feature/use-python-dockerfile
55+
with:
56+
matrix: '{ os: [ubuntu-latest, windows-latest], python-version: [3.8, 3.10, 3.12] }'
57+
continue-on-error: true
58+
- if: steps.expected-to-fail.outcome != 'failure'
59+
run: echo "Step expected to fail didn't fail" && exit 1
60+
setup-matrix-macos:
61+
runs-on: macos-latest
62+
steps:
63+
- id: expected-to-fail
64+
uses: druzsan/setup-matrix@feature/use-python-dockerfile
65+
with:
66+
matrix: '{ os: [ubuntu-latest, windows-latest], python-version: [3.8, 3.10, 3.12] }'
67+
continue-on-error: true
68+
- if: steps.expected-to-fail.outcome != 'failure'
69+
run: echo "Step expected to fail didn't fail" && exit 1

.github/workflows/quickstart.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: '⏱️ Quickstart'
2+
3+
on:
4+
push:
5+
schedule:
6+
- cron: '0 6 * * *'
7+
workflow_dispatch:
8+
9+
# This workflow serves for multiple purposes:
10+
# - Action integration test
11+
# - Quickstart example
12+
13+
jobs:
14+
# Setup matrix
15+
setup-matrix:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
matrix: ${{ steps.setup-matrix.outputs.matrix }}
19+
steps:
20+
- id: setup-matrix
21+
uses: druzsan/setup-matrix@feature/use-python-dockerfile
22+
with:
23+
# Use | to preserve valid YAML syntax
24+
matrix: |
25+
fruit: [apple, pear]
26+
animal: [quick red fox, lazy dog]
27+
include:
28+
- color: green
29+
- color: pink
30+
animal: quick red fox
31+
- color: brown
32+
animal: cat
33+
exclude:
34+
- fruit: apple
35+
animal: lazy dog
36+
# Setup python and print version
37+
echo:
38+
needs: setup-matrix
39+
strategy:
40+
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
41+
runs-on: ubuntu-latest
42+
steps:
43+
- run: |
44+
echo "fruit: ${{ matrix.fruit }}, animal: ${{ matrix.fruit }}, color: ${{ matrix.color }}"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: '🧪 Unit Test (built-in matrix)'
2+
3+
on: push
4+
5+
# This workflow serves for multiple purposes:
6+
# - Action code test
7+
# - Action integration test
8+
# - Advanced usage example (dynamic matrix)
9+
10+
jobs:
11+
# Run unit-test on a dev branch
12+
unit-test-dev:
13+
name: '🧪 Unit-Test (dev)'
14+
if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/')
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.8'
21+
- run: python -m pip install -IU pip setuptools wheel
22+
- run: pip install -IUr requirements.txt -r requirements-dev.txt
23+
- run: python -m pytest
24+
# Run unit-test on the main branch
25+
unit-test-main:
26+
name: '🧪 Unit-Test (main)'
27+
if: github.ref == 'refs/heads/main'
28+
strategy:
29+
matrix:
30+
os: [ubuntu-latest]
31+
python-version: ['3.8', '3.10', '3.12']
32+
include:
33+
- os: windows-latest
34+
python-version: '3.8'
35+
- os: macos-latest
36+
python-version: '3.8'
37+
runs-on: ${{ matrix.os }}
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: actions/setup-python@v5
41+
with:
42+
python-version: ${{ matrix.python-version }}
43+
- run: python -m pip install -IU pip setuptools wheel
44+
- run: pip install -IUr requirements.txt -r requirements-dev.txt
45+
- run: python -m pytest
46+
# Run unit-test on a tag
47+
unit-test-tag:
48+
name: '🧪 Unit-Test (tag)'
49+
if: startsWith(github.ref, 'refs/tags/')
50+
strategy:
51+
matrix:
52+
os: [ubuntu-latest, windows-latest, macos-latest]
53+
python-version: ['3.8', '3.10', '3.12']
54+
runs-on: ${{ matrix.os }}
55+
steps:
56+
- uses: actions/checkout@v4
57+
- uses: actions/setup-python@v5
58+
with:
59+
python-version: ${{ matrix.python-version }}
60+
- run: python -m pip install -IU pip setuptools wheel
61+
- run: pip install -IUr requirements.txt -r requirements-dev.txt
62+
- run: python -m pytest

.github/workflows/unit-test.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: '🧪 Unit Test'
2+
3+
on:
4+
push:
5+
schedule:
6+
- cron: '0 6 * * *'
7+
workflow_dispatch:
8+
9+
# This workflow serves for multiple purposes:
10+
# - Action code test
11+
# - Action integration test
12+
# - Advanced usage example (dynamic matrix)
13+
14+
jobs:
15+
# Setup matrix
16+
setup-matrix:
17+
name: '🧱 Build Matrix'
18+
runs-on: ubuntu-latest
19+
outputs:
20+
matrix: ${{ steps.setup-matrix.outputs.matrix }}
21+
steps:
22+
# Setup matrix on a dev branch
23+
- if: startsWith(github.ref, 'refs/tags/')
24+
uses: druzsan/setup-matrix@feature/use-python-dockerfile
25+
with:
26+
matrix: |
27+
os: [ubuntu-latest, windows-latest, macos-latest]
28+
python-version: [3.8, 3.10, 3.12]
29+
# Setup matrix on the main branch
30+
- if: github.ref == 'refs/heads/main'
31+
uses: druzsan/setup-matrix@feature/use-python-dockerfile
32+
with:
33+
matrix: |
34+
os: [ubuntu-latest]
35+
python-version: [3.8, 3.10, 3.12]
36+
include:
37+
- os: windows-latest
38+
python-version: 3.8
39+
- os: macos-latest
40+
python-version: 3.8
41+
# Setup matrix on a tag
42+
- if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/')
43+
uses: druzsan/setup-matrix@feature/use-python-dockerfile
44+
with:
45+
matrix: |
46+
os: [ubuntu-latest]
47+
python-version: [3.8]
48+
# MATRIX environment variable is set by the last executed action
49+
- id: setup-matrix
50+
run: echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
51+
# Run unit-test
52+
unit-test:
53+
name: '🧪 Unit-Test'
54+
needs: setup-matrix
55+
strategy:
56+
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
57+
runs-on: ${{ matrix.os }}
58+
steps:
59+
- uses: actions/checkout@v4
60+
- uses: actions/setup-python@v5
61+
with:
62+
python-version: ${{ matrix.python-version }}
63+
- run: python -m pip install -IU pip setuptools wheel
64+
- run: pip install -IUr requirements.txt -r requirements-dev.txt
65+
- run: python -m pytest

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1+
dev/
2+
13
.vscode/
24
.idea/
35
.direnv/
4-
.dev/
6+
.venv/
7+
8+
__pycache__/
9+
.mypy_cache/
10+
.pytest_cache/
11+
.ruff_cache/
12+
node_modules/

0 commit comments

Comments
 (0)