Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read

jobs:
# ── Job 1: Lint ────────────────────────────────────────────────────
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# TODO ②: Set up Python 3.11 using actions/setup-python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: ${{ runner.os }}-pip-

- name: Install linter
run: pip install ruff

- name: Run lint
run: ruff check src/

# ── Job 2: Test ────────────────────────────────────────────────────
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

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

- name: Install dependencies
run: pip install -r requirements.txt

- name: Run tests
run: pytest src/ --junitxml=test-results.xml

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: test-results.xml

# ── Job 3: Build ───────────────────────────────────────────────────
build:
name: Build
needs: [lint, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build distribution
run: |
pip install build
python -m build

- name: Upload dist artifact
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
6 changes: 3 additions & 3 deletions modules/02-github-actions/caching-and-matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
Expand Down Expand Up @@ -123,7 +123,7 @@ jobs:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
Expand Down Expand Up @@ -207,7 +207,7 @@ jobs:
python-version: ["3.11", "3.12"]

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
Expand Down
6 changes: 3 additions & 3 deletions modules/02-github-actions/environments-and-approvals.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ jobs:
runs-on: ubuntu-latest
environment: staging
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/checkout@v4
- run: ./scripts/deploy.sh
env:
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
Expand All @@ -133,7 +133,7 @@ jobs:
needs: deploy-staging
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/checkout@v4
- run: pytest tests/smoke/ --base-url=https://staging.securithings.com

deploy-production:
Expand All @@ -143,7 +143,7 @@ jobs:
name: production
url: https://app.securithings.com
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/checkout@v4
- run: ./scripts/deploy.sh
env:
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
Expand Down
22 changes: 11 additions & 11 deletions modules/02-github-actions/examples/01-basic-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Cache pip
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c6158d # v4.2.0
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
Expand All @@ -75,15 +75,15 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@v4

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

- name: Cache pip
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c6158d # v4.2.0
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}
Expand All @@ -95,7 +95,7 @@ jobs:
run: pytest src/ -v --junitxml=test-results-${{ matrix.python-version }}.xml

- name: Upload test results
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-py${{ matrix.python-version }}
Expand All @@ -119,10 +119,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
uses: actions/setup-python@v5
with:
python-version: "3.11"

Expand All @@ -136,7 +136,7 @@ jobs:
python -m build

- name: Upload dist
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
uses: actions/upload-artifact@v4
with:
name: dist-${{ steps.version.outputs.tag }}
path: dist/
Expand All @@ -151,7 +151,7 @@ jobs:

steps:
- name: Download dist
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
uses: actions/download-artifact@v4
with:
name: dist-${{ needs.build.outputs.version }}
path: dist/
Expand Down
14 changes: 7 additions & 7 deletions modules/02-github-actions/examples/02-matrix-build-advanced.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: python --version
Expand Down Expand Up @@ -56,9 +56,9 @@ jobs:
upload-results: false

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/checkout@v4

- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -76,7 +76,7 @@ jobs:

- name: Upload results
if: matrix.upload-results == true
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
uses: actions/upload-artifact@v4
with:
name: results-${{ matrix.name }}
path: "*.xml"
Expand All @@ -89,7 +89,7 @@ jobs:
outputs:
services: ${{ steps.list.outputs.services }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/checkout@v4
- id: list
run: |
# In reality, this might scan directories or query an API
Expand All @@ -106,6 +106,6 @@ jobs:
service: ${{ fromJSON(needs.generate-matrix.outputs.services) }}

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/checkout@v4
- name: Test service
run: echo "Testing service: ${{ matrix.service }}"
8 changes: 4 additions & 4 deletions modules/02-github-actions/examples/02-matrix-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ jobs:
coverage: true # Only run coverage on this combination

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/checkout@v4

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

- name: Cache pip (Unix)
if: runner.os != 'Windows'
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c6158d # v4.2.0
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}
Expand All @@ -63,7 +63,7 @@ jobs:

- name: Upload coverage
if: matrix.coverage == true
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:
version: ${{ steps.version.outputs.tag }}

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
uses: actions/setup-python@v5
with:
python-version: "3.11"

Expand All @@ -45,7 +45,7 @@ jobs:
python -m build

- name: Upload artifact
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
uses: actions/upload-artifact@v4
with:
name: dist-${{ steps.version.outputs.tag }}
path: dist/
Expand Down
4 changes: 2 additions & 2 deletions modules/02-github-actions/examples/03-reusable-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@v4

- name: Download artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
uses: actions/download-artifact@v4
with:
name: dist-${{ inputs.version }}
path: dist/
Expand Down
2 changes: 1 addition & 1 deletion modules/02-github-actions/examples/04-manual-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@v4

- name: Deploy
run: |
Expand Down
6 changes: 3 additions & 3 deletions modules/02-github-actions/exercises/exercise.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/checkout@v4

# TODO ②: Set up Python 3.11 using actions/setup-python

Expand All @@ -61,7 +61,7 @@ jobs:
# TODO ③: Add a matrix for python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/checkout@v4

# TODO ④: Set up Python from the matrix variable

Expand All @@ -79,7 +79,7 @@ jobs:
# TODO ⑥: Make this job wait for lint AND test to succeed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/checkout@v4

- name: Build distribution
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/checkout@v4
- run: pip install -r requirements.txt

test:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/checkout@v4
- run: pytest src/ --junitxml=report.xml
- uses: actions/upload-artifact@v4
if: always()
Expand All @@ -139,7 +139,7 @@ jobs:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/checkout@v4
- run: ./scripts/deploy.sh
env:
TOKEN: ${{ secrets.DEPLOY_TOKEN }}
Expand Down
Loading
Loading