Skip to content

Commit

Permalink
update github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianPugh committed Apr 25, 2024
1 parent b0d1c03 commit ba78014
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 29 deletions.
62 changes: 56 additions & 6 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Build package and push to PyPi

on:
workflow_dispatch:
push:
tags:
- "v*.*.*"
Expand All @@ -8,10 +10,58 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build and publish to pypi
uses: JRubics/poetry-publish@v1.16
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Includes getting tags

- name: Cache $HOME/.local # Significantly speeds up Poetry Install
uses: actions/cache@v4
with:
path: ~/.local
key: dotlocal-${{ runner.os }}-${{ hashFiles('.github/workflows/deploy.yml') }}

- name: Set up python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Add Poetry Plugins
run: |
poetry self add poetry-dynamic-versioning[plugin]
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --without=dev

- name: Install project
run: poetry install --no-interaction --without=dev

- name: Build package
run: poetry build

- name: Publish package
if: github.event_name != 'workflow_dispatch'
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
poetry publish
- uses: actions/upload-artifact@v4
if: always()
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
ignore_dev_requirements: "yes"
plugins: "poetry-dynamic-versioning[plugin]"
name: dist
path: dist/
14 changes: 8 additions & 6 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Cache $HOME/.local # Significantly speeds up Poetry Install
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.local
key: dotlocal-${{ runner.os }}-${{ hashFiles('.github/workflows/tests.yml') }}

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install Poetry
uses: snok/install-poetry@v1
Expand All @@ -34,20 +36,20 @@ jobs:
installer-parallel: true

- name: Load pip cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}
restore-keys: ${{ runner.os }}-pip

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install Belay
run: poetry install --no-interaction

- uses: pre-commit/action@v2.0.3
- uses: pre-commit/action@v3.0.1
28 changes: 11 additions & 17 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,22 @@ jobs:
echo 'ACTIVATE_PYTHON_VENV=.venv/bin/activate' >> $GITHUB_ENV
- name: Check out Belay repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check out RP2040js repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: wokwi/rp2040js
path: rp2040js

- name: Cache $HOME/.local # Significantly speeds up Poetry Install
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.local
key: dotlocal-${{ runner.os }}-${{ hashFiles('.github/workflows/tests.yml') }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -75,7 +75,7 @@ jobs:

- name: Cache Pi Pico MicroPython 1.17 firmware
id: cached-pi-pico-micropython-1-17-firmware
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: rp2040js/micropython-v1.17.uf2
key: pi-pico-rp2040js/micropython-v1.17.uf2
Expand All @@ -87,7 +87,7 @@ jobs:
- name: Cache Pi Pico CircuitPython 7.3.3 firmware
id: cached-pi-pico-circuitpython-7-3-3-firmware
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: rp2040js/circuitpython-v7.3.3.uf2
key: pi-pico-rp2040js/circuitpython-v7.3.3.uf2
Expand All @@ -99,7 +99,7 @@ jobs:
- name: Cache Pi Pico CircuitPython 8.0.0 firmware
id: cached-pi-pico-circuitpython-8-0-0-firmware
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: rp2040js/circuitpython-v8.0.0.uf2
key: pi-pico-rp2040js/circuitpython-v8.0.0.uf2
Expand All @@ -111,7 +111,7 @@ jobs:
- name: Cache Node Modules
id: cached-npm
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: rp2040js/node_modules
key: modules-${{ hashFiles('rp2040js/package-lock.json') }}
Expand All @@ -123,15 +123,15 @@ jobs:
npm install
- name: Load pip cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}
restore-keys: ${{ runner.os }}-pip

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
Expand All @@ -143,12 +143,6 @@ jobs:
- name: Install Belay
run: poetry install --no-interaction

- name: Collect Workflow Telemetry
uses: runforesight/workflow-telemetry-action@v1
with:
theme: light
comment_on_pr: false

- name: Run tests (unit only)
if: runner.os == 'Windows'
run: |
Expand All @@ -164,7 +158,7 @@ jobs:
coverage report
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
Expand Down

0 comments on commit ba78014

Please sign in to comment.