Skip to content

Commit

Permalink
CI: Merged FreeBSD VM setup in a github action (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
francis-clairicia authored Nov 11, 2024
1 parent 1a4a8fc commit 7087e4a
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 38 deletions.
48 changes: 48 additions & 0 deletions .github/actions/freebsd-vm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: 'FreeBSD VM'
description: 'Install FreeBSD VM with python3, PDM and tox pre-installed'
inputs:
python-version:
description: "Version range or exact version of Python to use, using SemVer's version range syntax."
required: true
run:
description: 'The CI command to run'
required: true
release:
description: 'The release version of FreeBSD vm'
required: false
envs:
description: 'The envs to pass into FreeBSD vm'
required: false
sync:
description: 'How to synchronize the source code to/from the VM, Values can be: rsync(default), and sshfs'
required: false

runs:
using: 'composite'
steps:
- name: Load PDM configuration from pdm.conf
uses: cardinalby/export-env-action@v2
with:
envFile: .github/actions/pdm.conf
- name: Load Python configuration
uses: cardinalby/export-env-action@v2
with:
envFile: ${{ github.action_path }}/python/${{ inputs.python-version }}.conf
- name: Run on VM
uses: vmactions/freebsd-vm@v1
with:
release: ${{ inputs.release }}
usesh: true
envs: ${{ inputs.envs }}
sync: ${{ inputs.sync }}
prepare: |
set -e
pkg install -y curl git ${{ env.FREEBSD_PORTS_FOR_PYTHON }}
curl -sSL https://pdm-project.org/install-pdm.py | ${{ env.FREEBSD_PYTHON_BIN }} - --version=${{ env.PDM_VERSION }} --path=/usr/local
pdm config check_update false
pdm config install.cache true
run: |
set -e
pdm install --frozen-lockfile --global --project=. --no-self --no-default --dev --group=tox
tox --version
${{ inputs.run }}
3 changes: 3 additions & 0 deletions .github/actions/freebsd-vm/python/3.11.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# py311-sqlite3 is needed for coverage.py
FREEBSD_PORTS_FOR_PYTHON=python311 py311-sqlite3
FREEBSD_PYTHON_BIN=python3.11
7 changes: 7 additions & 0 deletions .github/actions/pdm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file is loaded in runner environment by:
# - setup-tox
# - freebsd-vm

PDM_VERSION=2.20.1
PDM_CHECK_UPDATE=False
WORKFLOW_CACHE_KEY_FILE=.github/.workflow.cache.key
15 changes: 7 additions & 8 deletions .github/actions/setup-tox/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ inputs:
runs:
using: 'composite'
steps:
- name: Disable PDM update check
run: echo "PDM_CHECK_UPDATE=False" >> $GITHUB_ENV
shell: bash
- name: Get workflow cache key filepath
run: echo "WORKFLOW_CACHE_KEY_FILE=.github/.workflow.cache.key" >> $GITHUB_ENV
shell: bash
- name: Load PDM configuration from pdm.conf
uses: cardinalby/export-env-action@v2
with:
envFile: .github/actions/pdm.conf
- name: Create cache key from workflow
run: |
echo "Runner=${{ runner.os }}-${{ runner.arch }}; Workflow=${{ github.workflow }}/${{ github.job }}" > $WORKFLOW_CACHE_KEY_FILE
Expand All @@ -31,10 +29,11 @@ runs:
shell: bash
# Use a pinned commit to use the new feature added (and which is not currently added to v4)
# c.f. https://github.com/pdm-project/setup-pdm/pull/60
- uses: pdm-project/setup-pdm@2f3a9be7ac56a6e5c1ea605f8e9d0f0500363705 # v4
- name: Install PDM
uses: pdm-project/setup-pdm@2f3a9be7ac56a6e5c1ea605f8e9d0f0500363705 # v4
id: pdm
with:
version: '2.20.1'
version: ${{ env.PDM_VERSION }}
python-version: ${{ inputs.python-version }}
cache: true
cache-restore-exact-match: true
Expand Down
16 changes: 2 additions & 14 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

env:
PDM_VERSION: '2.20.1' # Used by FreeBSD VM

jobs:
type-hinting:
if: |
Expand Down Expand Up @@ -79,18 +76,9 @@ jobs:
with:
fetch-depth: 0
- name: Launch checks
uses: vmactions/freebsd-vm@v1
uses: ./.github/actions/freebsd-vm
with:
release: '14.1'
usesh: true
prepare: |
set -e
pkg install -y curl git python311 py311-sqlite3
curl -sSL https://pdm-project.org/install-pdm.py | python3.11 - --version=${{ env.PDM_VERSION }} --path=/usr/local
pdm config check_update false
pdm config install.cache true
python-version: '3.11'
run: |
set -e
pdm install --frozen-lockfile --global --project=. --no-self --no-default --dev --group=tox
tox --version
tox --workdir /tmp/.tox run -e mypy-full
18 changes: 2 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ concurrency:

env:
PYTEST_VERBOSE_FLAG: ${{ inputs.verbose && '-v' || '' }}
PDM_VERSION: '2.20.1' # Used by FreeBSD VM

jobs:
tests:
Expand Down Expand Up @@ -122,11 +121,7 @@ jobs:
# TODO: Add test with other python version
# c.f. https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271673
include:
# py3XX-sqlite3 is needed for coverage.py
- python_version: '3.11'
freebsd_ports: >-
python311
py311-sqlite3
tox_py: py311

name: test (freebsd-14, ${{ matrix.python_version }})
Expand All @@ -137,20 +132,11 @@ jobs:
- name: Launch tests
# Add 5 minutes to let the VM boot and install dependencies
timeout-minutes: 25
uses: vmactions/freebsd-vm@v1
uses: ./.github/actions/freebsd-vm
with:
release: '14.1'
usesh: true
prepare: |
set -e
pkg install -y curl git ${{ matrix.freebsd_ports }}
curl -sSL https://pdm-project.org/install-pdm.py | python${{ matrix.python_version }} - --version=${{ env.PDM_VERSION }} --path=/usr/local
pdm config check_update false
pdm config install.cache true
python-version: ${{ matrix.python_version }}
run: |
set -e
pdm install --frozen-lockfile --global --project=. --no-self --no-default --dev --group=tox
tox --version
tox --workdir /tmp/.tox run -f ${{ matrix.tox_py }} -- ${{ env.PYTEST_VERBOSE_FLAG }}
tox --workdir /tmp/.tox run -f coverage
- name: Check files in workspace
Expand Down

0 comments on commit 7087e4a

Please sign in to comment.