Skip to content

Translations update #742

Translations update

Translations update #742

Workflow file for this run

name: CI
on:
push:
branches:
- master
tags:
- "v*"
pull_request:
branches:
- master
env:
REGISTRY: ghcr.io
IMAGE_NAME: donkie/spoolman
jobs:
#
# Linting
#
style:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Set up Python
uses: actions/[email protected]
with:
python-version: "3.9"
- name: Install pre-commit
run: pip install pre-commit==3.3.3
- name: Run pre-commit
run: pre-commit run --all-files
#
# Build the Spoolman client for baking into the docker images
# This is done on native hardware to speed things up, vite is very slow on emulated hardware
#
build-client:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Install node
uses: actions/[email protected]
with:
node-version: '20'
- name: Set up Python
uses: actions/[email protected]
with:
python-version: "3.9"
- name: Export requirements
run: |
pip install pdm
pdm export -o requirements.txt --without-hashes
- name: Install client dependencies
run: |
cd client
npm ci
- name: Build
run: |
cd client
rm -f .env && echo "VITE_APIURL=/api/v1" > .env.production
npm run build
- name: Write build info
run: |
echo "GIT_COMMIT=$(git rev-parse --short HEAD)" > build.txt
echo "BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> build.txt
# Remove client source and keep only the built dist
- name: Clean
run: |
mv client/dist dist
rm -rf client
mkdir client
mv dist client/dist
rm -rf .git
rm -rf .venv
- name: Fix permissions
run: |
chmod +x scripts/*.sh
- name: Upload client Spoolman artifact
uses: actions/[email protected]
with:
name: client
path: client/dist
- name: Upload full Spoolman artifact
uses: actions/[email protected]
with:
include-hidden-files: true
name: spoolman
path: .
#
# Build native image for integration tests
#
build-amd64:
needs: [build-client]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Download client
uses: actions/[email protected]
with:
name: client
path: client/dist
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Log in to the Github Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Spoolman
if: ${{ github.event_name != 'pull_request' }}
uses: docker/[email protected]
with:
context: .
tags: ${{ env.IMAGE_NAME }}:test
outputs: type=docker,dest=/tmp/spoolman.tar
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-amd64
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-amd64,mode=max
# Separate build for pull requests since PRs dont have access to store cache
- name: Build Spoolman (PR)
if: ${{ github.event_name == 'pull_request' }}
uses: docker/[email protected]
with:
context: .
tags: ${{ env.IMAGE_NAME }}:test
outputs: type=docker,dest=/tmp/spoolman.tar
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-amd64
- name: Upload artifact
uses: actions/[email protected]
with:
name: spoolman-image
path: /tmp/spoolman.tar
#
# Build tester image for integration tests
#
build-tester:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Log in to the Github Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Spoolman Tester
if: ${{ github.event_name != 'pull_request' }}
uses: docker/[email protected]
with:
context: ./tests_integration
tags: ${{ env.IMAGE_NAME }}-tester:latest
outputs: type=docker,dest=/tmp/spoolman-tester.tar
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-tester
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-tester,mode=max
# Separate build for pull requests since PRs dont have access to store cache
- name: Build Spoolman Tester (PR)
if: ${{ github.event_name == 'pull_request' }}
uses: docker/[email protected]
with:
context: ./tests_integration
tags: ${{ env.IMAGE_NAME }}-tester:latest
outputs: type=docker,dest=/tmp/spoolman-tester.tar
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-tester
- name: Upload artifact
uses: actions/[email protected]
with:
name: spoolman-tester-image
path: /tmp/spoolman-tester.tar
#
# Perform integration tests
#
test:
needs: [build-amd64, build-tester]
strategy:
matrix:
dbtype: ["postgres", "sqlite", "mariadb", "cockroachdb"]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Download built images
uses: actions/[email protected]
with:
pattern: spoolman*-image
path: /tmp
- name: Load built images
run: |
docker load --input /tmp/spoolman-image/spoolman.tar
docker load --input /tmp/spoolman-tester-image/spoolman-tester.tar
- name: Perform integration tests
uses: hoverkraft-tech/[email protected]
with:
compose-file: "./tests_integration/docker-compose-${{ matrix.dbtype }}.yml"
up-flags: "--abort-on-container-exit"
down-flags: "--volumes"
#
# Build arm64 image
# Don't run this for pull requests
# Only push to buildcache and let release job push to registry
#
build-arm64:
if: ${{ github.event_name != 'pull_request' }}
needs: [build-client]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Download client
uses: actions/[email protected]
with:
name: client
path: client/dist
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Log in to the Github Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and cache Docker image
uses: docker/[email protected]
with:
context: .
platforms: linux/arm64
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-arm64
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-arm64,mode=max
#
# Build arm/v7 image
# Don't run this for pull requests
# Only push to buildcache and let release job push to registry
#
build-armv7:
if: ${{ github.event_name != 'pull_request' }}
needs: [build-client]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Download client
uses: actions/[email protected]
with:
name: client
path: client/dist
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Log in to the Github Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and cache Docker image
uses: docker/[email protected]
with:
context: .
platforms: linux/arm/v7
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-armv7
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-armv7,mode=max
#
# Release image if tests pass
# Don't run this for pull requests
#
publish-images:
if: ${{ github.event_name != 'pull_request' }}
needs: [test, build-amd64, build-arm64, build-armv7, style, build-client]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Download client
uses: actions/[email protected]
with:
name: client
path: client/dist
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Log in to the Github Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=edge
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Store git commit and build date
run: |
echo "GIT_COMMIT=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
echo "BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> "$GITHUB_ENV"
- name: Build and push Docker images
uses: docker/[email protected]
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GIT_COMMIT
BUILD_DATE
cache-from: |
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-amd64
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-arm64
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-armv7
#
# Create Github Release if CI was triggered by a tag
#
publish-release:
if: ${{ (github.event_name != 'pull_request') && startsWith(github.event.ref, 'refs/tags/v') }}
needs: [publish-images]
runs-on: ubuntu-latest
steps:
- name: Download built spoolman
uses: actions/[email protected]
with:
name: spoolman
path: /tmp/spoolman
- name: Generate release info
run: |
cd /tmp/spoolman
echo '{
"project_name": "Spoolman",
"project_owner": "Donkie",
"version": "${{ github.ref_name }}"
}' > release_info.json
- name: Zip
run: |
cd /tmp/spoolman
zip -r spoolman.zip .
- name: Create release and upload build
uses: softprops/action-gh-release@v1
id: create-release
with:
draft: true
name: ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
files: /tmp/spoolman/spoolman.zip
token: ${{ secrets.GITHUB_TOKEN }}
body: "⚠️ TODO ⚠️"