Skip to content

Commit

Permalink
ci: Update actions and merge test with build
Browse files Browse the repository at this point in the history
  • Loading branch information
null2264 committed Aug 21, 2024
1 parent 1e4d6fb commit 97b6eeb
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 101 deletions.
64 changes: 56 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Build and Test

on:
push:
Expand All @@ -19,16 +19,64 @@ jobs:

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

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

- name: Get full Python version
id: full-python-version
run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT

- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y
- name: Configure poetry
run: poetry config virtualenvs.in-project true

- name: Set up cache
uses: actions/cache@v4
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}

- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: |
# `timeout` is not available on macOS, so we define a custom function.
[ "$(command -v timeout)" ] || function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
# Using `timeout` is a safeguard against the Poetry command hanging for some reason.
timeout 10s poetry run pip --version || rm -rf .venv
- name: Check lock file
run: poetry lock --check

- name: Install dependencies
run: |
sudo apt install ninja
poetry install --with github-actions,test
- name: Run pytest
env:
POETRY_TEST_INTEGRATION_GIT_USERNAME: ${GITHUB_ACTOR}
POETRY_TEST_INTEGRATION_GIT_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
run: poetry run pytest -v

# --- Build

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
Expand All @@ -41,7 +89,7 @@ jobs:
echo "VERSION_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: Build and push (Nightly)
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
if: ${{ !startsWith(github.ref, 'refs/tags/') && github.ref_name == 'dev' && github.repository == 'ziro-bot/z3r0' }}
with:
context: .
Expand All @@ -50,7 +98,7 @@ jobs:
tags: ghcr.io/ziro-bot/z3r0:nightly

- name: Build and push (Canary)
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
if: ${{ !startsWith(github.ref, 'refs/tags/') && github.ref_name == 'overhaul' && github.repository == 'ziro-bot/z3r0' }}
with:
context: .
Expand All @@ -59,7 +107,7 @@ jobs:
tags: ghcr.io/ziro-bot/z3r0:canary

- name: Build and push (Release)
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'ziro-bot/z3r0'
with:
context: .
Expand Down
93 changes: 0 additions & 93 deletions .github/workflows/test.yml

This file was deleted.

0 comments on commit 97b6eeb

Please sign in to comment.