Skip to content

Better handle OPDS server root content types. (PP-1959) #1995

Better handle OPDS server root content types. (PP-1959)

Better handle OPDS server root content types. (PP-1959) #1995

Workflow file for this run

name: Test & Build
on: [push, pull_request]
jobs:
test:
name: Test
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
# We want to run on external PRs, but not on our own internal PRs as they'll be run
# by the push to the branch. This prevents duplicated runs on internal PRs.
# Some discussion of this here:
# https://gh.neting.ccmunity/t/duplicate-checks-on-push-and-pull-request-simultaneous-event/18012
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: ThePalaceProject/circulation/.github/actions/poetry@main
with:
version: "1.5.1"
- name: Install Tox
run: |
poetry install --only ci
env:
POETRY_VIRTUALENVS_CREATE: false
- name: Run Tests
run: tox
build:
name: Docker build
runs-on: ubuntu-latest
needs: [test]
permissions:
contents: read
packages: write
env:
REGISTRY_HOST: ghcr.io
# Push the built docker image only in the following cases:
# - The `NO_DOCKER_IMAGE` secret is not set. (Useful if you want to disable pushing
# of docker images in local forks of this repo).
# - The branch name does not start with `dependabot/`. The dependabot service does not
# have the proper security token to push to github packages.
# - The event that triggered this action was a `push`. If it was a PR the github action
# context will not have permissions to push the image to github packages.
IMAGE_PUSH_ENABLED: ${{
secrets.NO_DOCKER_IMAGE == null &&
!startsWith(github.ref, 'refs/heads/dependabot/') &&
github.event_name == 'push'
}}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install Poetry
uses: ThePalaceProject/circulation/.github/actions/poetry@main
with:
version: "1.5.1"
- name: Setup Dunamai
run: poetry install --only ci
env:
POETRY_VIRTUALENVS_CREATE: false
- name: Create version file
run: |
echo "__version__ = '$(dunamai from git --style semver)'" >> admin/_version.py
echo "__commit__ = '$(dunamai from git --format {commit} --full-commit)'" >> admin/_version.py
echo "__branch__ = '$(dunamai from git --format {branch})'" >> admin/_version.py
- name: Login to the Docker registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY_HOST }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
if: env.IMAGE_PUSH_ENABLED == 'true'
- name: Generate tags
id: library-registry-tags
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_HOST }}/${{ github.repository_owner }}/library-registry
tags: |
type=semver,pattern={{major}}.{{minor}},priority=10
type=semver,pattern={{version}},priority=20
type=ref,event=branch,priority=30
type=sha,priority=40
- name: Build image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
target: libreg_active
push: ${{ env.IMAGE_PUSH_ENABLED }}
tags: ${{ steps.library-registry-tags.outputs.tags }}
platforms: linux/amd64, linux/arm64