Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

1.2.0 #33

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
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
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
102 changes: 46 additions & 56 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,68 +1,58 @@
name: CI
on:
push:
branches: [main]
branches:
- main
pull_request:
branches:
- main

defaults:
run:
shell: bash

jobs:
test:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# If you wanted to use multiple Python versions, you'd have specify a matrix in the job and
# reference the matrixe python version here.
- uses: actions/setup-python@v2
with:
python-version: 3.9

# Cache the installation of Poetry itself, e.g. the next step. This prevents the workflow
# from installing Poetry every time, which can be slow. Note the use of the Poetry version
# number in the cache key, and the "-0" suffix: this allows you to invalidate the cache
# manually if/when you want to upgrade Poetry, or if something goes wrong. This could be
# mildly cleaner by using an environment variable, but I don't really care.
- name: cache poetry install
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-1.1.14-0
- name: Checkout code
uses: actions/checkout@v4

# Install Poetry. You could do this manually, or there are several actions that do this.
# `snok/install-poetry` seems to be minimal yet complete, and really just calls out to
# Poetry's default install script, which feels correct. I pin the Poetry version here
# because Poetry does occasionally change APIs between versions and I don't want my
# actions to break if it does.
#
# The key configuration value here is `virtualenvs-in-project: true`: this creates the
# venv as a `.venv` in your testing directory, which allows the next step to easily
# cache it.
- uses: snok/install-poetry@v1
- name: Poetry install
uses: ./.github/actions/poetry-install
with:
version: 1.1.14
virtualenvs-create: true
virtualenvs-in-project: true

# Cache your dependencies (i.e. all the stuff in your `pyproject.toml`). Note the cache
# key: if you're using multiple Python versions, or multiple OSes, you'd need to include
# them in the cache key. I'm not, so it can be simple and just depend on the poetry.lock.
- name: cache deps
id: cache-deps
uses: actions/cache@v2
with:
path: .venv
key: pydeps-${{ hashFiles('**/poetry.lock') }}

# Install dependencies. `--no-root` means "install all dependencies but not the project
# itself", which is what you want to avoid caching _your_ code. The `if` statement
# ensures this only runs on a cache miss.
- run: poetry install --no-interaction --no-root
if: steps.cache-deps.outputs.cache-hit != 'true'

# Now install _your_ project. This isn't necessary for many types of projects -- particularly
# things like Django apps don't need this. But it's a good idea since it fully-exercises the
# pyproject.toml and makes that if you add things like console-scripts at some point that
# they'll be installed and working.
- run: poetry install --no-interaction
python-version: '3.12'
poetry-version: '1.8.4'

- name: Code Quality
run: poetry run black . --check
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
Loading