Skip to content

Commit

Permalink
dev: Add CI test step
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlesne committed Dec 5, 2024
1 parent ed7ceac commit 1b29ea8
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
64 changes: 62 additions & 2 deletions .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: pipeline
name: Pipeline

on:
push:
Expand Down Expand Up @@ -86,6 +86,65 @@ jobs:
with:
sarif_file: semgrep.sarif

test:
name: Test
permissions:
id-token: write
runs-on: ubuntu-24.04
needs:
- init
strategy:
fail-fast: false
matrix:
# Run all test suites
step:
- static
# TODO: Enable unit tests (Azure login and config file required)
# - unit
steps:
- name: Checkout
uses: actions/[email protected]

- name: Set up uv
uses: astral-sh/[email protected]
with:
enable-cache: true
python-version: "3.12"
version: "0.5.x"

# - name: Login to Azure
# uses: Azure/[email protected]
# with:
# client-id: ${{ secrets.AZURE_CLIENT_ID }}
# subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# tenant-id: ${{ secrets.AZURE_TENANT_ID }}

- name: Cache pytest
uses: actions/[email protected]
with:
key: pytest-${{ github.head_ref || github.ref_name }}-${{ hashFiles('requirements-dev.txt') }}
path: .pytest_cache

- name: Cache Ruff
uses: actions/[email protected]
with:
key: ruff-${{ github.head_ref || github.ref_name }}-${{ hashFiles('requirements-dev.txt') }}
path: .ruff_cache

# - name: Configure environment variables
# run: echo "${{ secrets.DOTENV_UNIT_TESTS }}" > .env

- name: Run tests
run: make test-${{ matrix.step }} version_full=${{ needs.init.outputs.VERSION_FULL }}

- name: Upload artifacts
uses: actions/[email protected]
if: always()
with:
compression-level: 9
name: test-${{ matrix.step }}
path: test-reports/*

build-image:
name: Build & publish image
needs:
Expand Down Expand Up @@ -168,8 +227,9 @@ jobs:
create-release:
name: Create release
needs:
- init
- build-image
- init
- test
permissions:
# Allow to create releases
contents: write
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,17 @@ upgrade:
az bicep upgrade

test:
$(MAKE) test-static
$(MAKE) test-unit

test-static:
@echo "➡️ Test code smells (Ruff)..."
uv run ruff check --select I,PL,RUF,UP,ASYNC,A,DTZ,T20,ARG,PERF --ignore RUF012

@echo "➡️ Test types (Pyright)..."
uv run pyright .

test-unit:
@echo "➡️ Unit tests (Pytest)..."
PUBLIC_DOMAIN=dummy uv run pytest \
--junit-xml=test-reports/$(version_full).xml \
Expand Down

0 comments on commit 1b29ea8

Please sign in to comment.