From 4301d3a7033f83497ad2a5ba6861a64f0917772f Mon Sep 17 00:00:00 2001 From: Tom de Bruijn Date: Thu, 11 Jan 2024 16:39:49 +0100 Subject: [PATCH 1/2] Use GitHub Actions as the CI Move away from Semaphore and use GitHub Actions as our CI for this project. Semaphore doesn't have Python 12 yet for us to test against, it will update versions once a month, and with GitHub Actions we can run it on the CI today. [skip changeset] --- .github/workflows/ci.yml | 54 +++++++++++++++++++++++++++++++++ .semaphore/semaphore.yml | 65 ---------------------------------------- pyproject.toml | 3 +- script/lint_git | 22 -------------- 4 files changed, 56 insertions(+), 88 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .semaphore/semaphore.yml delete mode 100755 script/lint_git diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..ea4fcb7f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,54 @@ +name: Python package +on: [push] +jobs: + test: + name: "Test Python ${{ matrix.python-version }}" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: "Install hatch" + run: "pip install hatch" + - name: "Run tests" + run: "hatch -v run test.py$(echo ${{ matrix.python-version }} | tr -d '.'):pytest" + + lint-style: + name: "Style linter" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.12 + - name: "Install hatch" + run: "pip install hatch" + - name: "Run style linter" + run: "hatch -v run lint:style" + + lint-typing: + name: "Typing linter" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.12 + - name: "Install hatch" + run: "pip install hatch" + - name: "Run typing linter" + run: "hatch -v run lint:typing" + + lint-git: + name: "Git linter (Lintje)" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch depth is required + - uses: lintje/action@v0.11 diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml deleted file mode 100644 index 999aaaf3..00000000 --- a/.semaphore/semaphore.yml +++ /dev/null @@ -1,65 +0,0 @@ -version: v1.0 -name: AppSignal for Python -auto_cancel: - running: - when: branch != 'main' AND branch != 'develop' -agent: - machine: - type: e1-standard-2 - os_image: ubuntu2004 -global_job_config: - prologue: - commands: - - checkout -blocks: -- name: Linters - dependencies: [] - task: - jobs: - - name: Style - commands: - - "sem-version python 3.11" - - "pip install hatch" - - "hatch -v run lint:style" - - name: Typing - commands: - - "sem-version python 3.11" - - "pip install hatch" - - "hatch -v run lint:typing" - - name: Git Lint (Lintje) - commands: - - script/lint_git -- name: Tests - dependencies: [] - task: - jobs: - - name: Diagnose tests - env_vars: - - name: LANGUAGE - value: python - commands: - - "sem-version python 3.11" - - "pip install hatch" - - git submodule init - - git submodule update - - ./tests/diagnose/bin/test - - name: Python 3.8 - commands: - - "sem-version python 3.8" - - "pip install hatch" - - "hatch -v run test.py38:pytest" - - name: Python 3.9 - commands: - - "sem-version python 3.9" - - "pip install hatch" - - "hatch -v run test.py39:pytest" - - name: Python 3.10 - commands: - - "sem-version python 3.10" - - "pip install hatch" - - "hatch -v run test.py310:pytest" - - name: Python 3.11 - commands: - - "sem-version python 3.11" - - "pip install hatch" - - "hatch -v run test.py311:pytest" diff --git a/pyproject.toml b/pyproject.toml index 72b93bde..887b3bc6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,6 +20,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", # Application version @@ -72,7 +73,7 @@ dependencies = [ ] [[tool.hatch.envs.test.matrix]] -python = ["38", "39", "310", "311"] +python = ["38", "39", "310", "311", "312"] [tool.hatch.envs.lint] detached = true diff --git a/script/lint_git b/script/lint_git deleted file mode 100755 index 11cf375b..00000000 --- a/script/lint_git +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -set -eu - -LINTJE_VERSION="0.11.3" - -mkdir -p "$HOME/bin" -cache_key=v1-lintje-$LINTJE_VERSION -cache restore $cache_key - -# File exists and is executable -if [ -x "$HOME/bin/lintje" ]; then - echo "Restored Lintje $LINTJE_VERSION from cache" -else - echo "Downloading Lintje $LINTJE_VERSION" - curl -L \ - https://github.com/lintje/lintje/releases/download/v$LINTJE_VERSION/x86_64-unknown-linux-gnu.tar.gz | \ - tar -xz --directory "$HOME/bin" - cache store $cache_key "$HOME/bin/lintje" -fi - -"$HOME/bin/lintje" "$SEMAPHORE_GIT_COMMIT_RANGE" From b0b8abe1798e339a3e3bb861a5b8cf7533b7c995 Mon Sep 17 00:00:00 2001 From: Tom de Bruijn Date: Thu, 11 Jan 2024 17:52:06 +0100 Subject: [PATCH 2/2] Add scheduled CI build Run the build every Monday through Friday. --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea4fcb7f..2a9f11c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,8 @@ name: Python package -on: [push] +on: + push: {} + schedule: + - cron: "0 0 * * 1-5" jobs: test: name: "Test Python ${{ matrix.python-version }}"