Skip to content

Commit

Permalink
Merge pull request #6 from druzsan/feature/use-python-dockerfile
Browse files Browse the repository at this point in the history
Feature/use python dockerfile
  • Loading branch information
druzsan authored Feb 9, 2024
2 parents 91f5fe9 + abdb771 commit c71074a
Show file tree
Hide file tree
Showing 19 changed files with 958 additions and 250 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*

!Dockerfile
!requirements.txt
!main.py
58 changes: 58 additions & 0 deletions .github/workflows/ci-builtin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: '🔍 CI (built-in matrix)'

on: push

# This workflow serves for multiple purposes:
# - Action code check
# - Action integration test
# - Advanced usage example (reusable matrix)

jobs:
# Check code formatting
check-format:
name: '🔍 Check Formatting'
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.10', '3.12']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install -IU pip setuptools wheel
- run: pip install -IUr requirements.txt -r requirements-dev.txt
- run: black --check .
# Check code types
typecheck:
name: '🔍 Check Types'
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.10', '3.12']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install -IU pip setuptools wheel
- run: pip install -IUr requirements.txt -r requirements-dev.txt
- run: mypy main.py && mypy tests
# Lint code
lint:
name: '🔍 Lint'
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.10', '3.12']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install -IU pip setuptools wheel
- run: pip install -IUr requirements.txt -r requirements-dev.txt
- run: ruff check main.py tests
68 changes: 68 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: '🔍 CI'

on: push

# This workflow serves for multiple purposes:
# - Action code check
# - Action integration test
# - Advanced usage example (reusable matrix)

jobs:
# Setup matrix
setup-matrix:
name: '🧱 Build Matrix'
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.setup-matrix.outputs.matrix }}
steps:
- id: setup-matrix
uses: druzsan/setup-matrix@feature/use-python-dockerfile
with:
matrix: |
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.8, 3.10, 3.12]
# Check code formatting
check-format:
name: '🔍 Check Formatting'
needs: setup-matrix
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install -IU pip setuptools wheel
- run: pip install -IUr requirements.txt -r requirements-dev.txt
- run: black --check .
# Check code types
typecheck:
name: '🔍 Check Types'
needs: setup-matrix
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install -IU pip setuptools wheel
- run: pip install -IUr requirements.txt -r requirements-dev.txt
- run: mypy main.py && mypy tests
# Lint code
lint:
name: '🔍 Lint'
needs: setup-matrix
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install -IU pip setuptools wheel
- run: pip install -IUr requirements.txt -r requirements-dev.txt
- run: ruff check main.py tests
69 changes: 69 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: '🧪 Integration Test'

on:
push:
schedule:
- cron: '0 6 * * *'
workflow_dispatch:

# This workflow serves for multiple purposes:
# - Action integration test
# - Usage example

jobs:
# Valid jobs
setup-matrix-multi-line:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.setup-matrix.outputs.matrix }}
steps:
- uses: druzsan/setup-matrix@feature/use-python-dockerfile
with:
matrix: | # Setup matrix with OS and Python version
os: [ubuntu-latest, windows-latest]
python-version: [3.8, 3.10, 3.12]
include:
- os: windows-latest
python-version: 3.8 # Only use Python 3.8 for MacOS
exclude:
- os: windows-latest
python-version: 3.12 # Do not use Python 3.12 for Windows
setup-matrix-flow-syntax:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.setup-matrix.outputs.matrix }}
steps:
- uses: druzsan/setup-matrix@feature/use-python-dockerfile
with:
matrix: '{ os: [ubuntu-latest, windows-latest], python-version: [3.8, 3.10, 3.12] }'
# Jobs expected to fail
setup-matrix-empty:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.setup-matrix.outputs.matrix }}
steps:
- id: expected-to-fail
uses: druzsan/setup-matrix@feature/use-python-dockerfile
continue-on-error: true
- if: steps.expected-to-fail.outcome != 'failure'
run: echo "Step expected to fail didn't fail" && exit 1
setup-matrix-windows:
runs-on: windows-latest
steps:
- id: expected-to-fail
uses: druzsan/setup-matrix@feature/use-python-dockerfile
with:
matrix: '{ os: [ubuntu-latest, windows-latest], python-version: [3.8, 3.10, 3.12] }'
continue-on-error: true
- if: steps.expected-to-fail.outcome != 'failure'
run: echo "Step expected to fail didn't fail" && exit 1
setup-matrix-macos:
runs-on: macos-latest
steps:
- id: expected-to-fail
uses: druzsan/setup-matrix@feature/use-python-dockerfile
with:
matrix: '{ os: [ubuntu-latest, windows-latest], python-version: [3.8, 3.10, 3.12] }'
continue-on-error: true
- if: steps.expected-to-fail.outcome != 'failure'
run: echo "Step expected to fail didn't fail" && exit 1
44 changes: 44 additions & 0 deletions .github/workflows/quickstart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: '⏱️ Quickstart'

on:
push:
schedule:
- cron: '0 6 * * *'
workflow_dispatch:

# This workflow serves for multiple purposes:
# - Action integration test
# - Quickstart example

jobs:
# Setup matrix
setup-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.setup-matrix.outputs.matrix }}
steps:
- id: setup-matrix
uses: druzsan/setup-matrix@feature/use-python-dockerfile
with:
# Use | to preserve valid YAML syntax
matrix: |
fruit: [apple, pear]
animal: [quick red fox, lazy dog]
include:
- color: green
- color: pink
animal: quick red fox
- color: brown
animal: cat
exclude:
- fruit: apple
animal: lazy dog
# Setup python and print version
echo:
needs: setup-matrix
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
runs-on: ubuntu-latest
steps:
- run: |
echo "fruit: ${{ matrix.fruit }}, animal: ${{ matrix.fruit }}, color: ${{ matrix.color }}"
62 changes: 62 additions & 0 deletions .github/workflows/unit-test-builtin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: '🧪 Unit Test (built-in matrix)'

on: push

# This workflow serves for multiple purposes:
# - Action code test
# - Action integration test
# - Advanced usage example (dynamic matrix)

jobs:
# Run unit-test on a dev branch
unit-test-dev:
name: '🧪 Unit-Test (dev)'
if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.8'
- run: python -m pip install -IU pip setuptools wheel
- run: pip install -IUr requirements.txt -r requirements-dev.txt
- run: python -m pytest
# Run unit-test on the main branch
unit-test-main:
name: '🧪 Unit-Test (main)'
if: github.ref == 'refs/heads/main'
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.8', '3.10', '3.12']
include:
- os: windows-latest
python-version: '3.8'
- os: macos-latest
python-version: '3.8'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install -IU pip setuptools wheel
- run: pip install -IUr requirements.txt -r requirements-dev.txt
- run: python -m pytest
# Run unit-test on a tag
unit-test-tag:
name: '🧪 Unit-Test (tag)'
if: startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.10', '3.12']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install -IU pip setuptools wheel
- run: pip install -IUr requirements.txt -r requirements-dev.txt
- run: python -m pytest
65 changes: 65 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: '🧪 Unit Test'

on:
push:
schedule:
- cron: '0 6 * * *'
workflow_dispatch:

# This workflow serves for multiple purposes:
# - Action code test
# - Action integration test
# - Advanced usage example (dynamic matrix)

jobs:
# Setup matrix
setup-matrix:
name: '🧱 Build Matrix'
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.setup-matrix.outputs.matrix }}
steps:
# Setup matrix on a dev branch
- if: startsWith(github.ref, 'refs/tags/')
uses: druzsan/setup-matrix@feature/use-python-dockerfile
with:
matrix: |
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.8, 3.10, 3.12]
# Setup matrix on the main branch
- if: github.ref == 'refs/heads/main'
uses: druzsan/setup-matrix@feature/use-python-dockerfile
with:
matrix: |
os: [ubuntu-latest]
python-version: [3.8, 3.10, 3.12]
include:
- os: windows-latest
python-version: 3.8
- os: macos-latest
python-version: 3.8
# Setup matrix on a tag
- if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/')
uses: druzsan/setup-matrix@feature/use-python-dockerfile
with:
matrix: |
os: [ubuntu-latest]
python-version: [3.8]
# MATRIX environment variable is set by the last executed action
- id: setup-matrix
run: echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
# Run unit-test
unit-test:
name: '🧪 Unit-Test'
needs: setup-matrix
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install -IU pip setuptools wheel
- run: pip install -IUr requirements.txt -r requirements-dev.txt
- run: python -m pytest
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
dev/

.vscode/
.idea/
.direnv/
.dev/
.venv/

__pycache__/
.mypy_cache/
.pytest_cache/
.ruff_cache/
node_modules/
Loading

0 comments on commit c71074a

Please sign in to comment.