Skip to content

Commit

Permalink
test on all platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
b4ird committed Oct 31, 2024
1 parent 2f1b5c6 commit 971c325
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 28 deletions.
42 changes: 42 additions & 0 deletions .github/actions/poetry-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Poetry Install
description: Installs Python dependencies using Poetry

inputs:
poetry-version:
description: The version of Poetry to install
type: string
required: true
python-version:
description: The version of Python to use
type: string
required: true

defaults:
run:
shell: bash

runs:
using: composite
steps:
- name: Install Poetry
shell: bash
run: |
pipx install poetry==${{ inputs.poetry-version}}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
cache: 'poetry'
cache-dependency-path: poetry.lock

- name: Set Poetry environment
shell: bash
if: runner.os != 'Windows'
run: |
poetry env use ${{ inputs.python-version }}
- name: Install project dependencies
shell: bash
run: |
poetry install --no-interaction --no-root
33 changes: 33 additions & 0 deletions .github/workflows/_tests-matrix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Reusable workflow consumed by ci.yml; used to share a single matrix across jobs.
on:
workflow_call:
inputs:
runner:
required: true
type: string
python-version:
required: true
type: string
poetry-version:
required: true
type: string

defaults:
run:
shell: bash

jobs:
tests:
runs-on: ${{ inputs.runner }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- uses: ./.github/actions/poetry-install
with:
python-version: ${{ inputs.python-version }}
poetry-version: ${{ inputs.poetry-version }}

- name: Run unit tests
run: |
poetry run pytest spotify_sync/tests
72 changes: 44 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,58 @@
name: CI
on:
push:
branches: [main]
branches:
- main
pull_request:
branches:
- main

defaults:
run:
shell: bash

jobs:
build-and-test:
name: Build and test
lint:
name: Lint
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.11']

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Poetry
run: |
pipx install poetry==1.8.4
- name: Set up Python
uses: actions/setup-python@v5
- name: Poetry install
uses: ./.github/actions/poetry-install
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
cache-dependency-path: poetry.lock

- name: Set Poetry environment
run: |
poetry env use ${{ matrix.python-version }}
- name: Install project dependencies
run: |
poetry install --no-interaction --no-root
python-version: '3.12'
poetry-version: '1.8.4'

- name: Code Quality
run: poetry run black . --check

- name: Unit Tests
run: poetry run pytest spotify_sync/tests
run: |
poetry run black . --check
unit-tests:
name: "Unit tests (${{ matrix.python-version }} ${{ matrix.os.name }})"
uses: ./.github/workflows/_tests-matrix.yml
needs: lint
with:
runner: ${{ matrix.os.image }}
python-version: ${{ matrix.python-version }}
poetry-version: '1.8.4'
strategy:
matrix:
os:
# - name: Ubuntu
# image: ubuntu-22.04
# - name: macOS x86_64
# image: macos-13
- name: Windows
image: windows-2022
# - name: macOS aarch64
# image: macos-14
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.11'
- '3.12'
fail-fast: false

0 comments on commit 971c325

Please # to comment.