A journey to fix `ValidationError` in Pocket imports turned service layer refactoring :D
163 lines
5.7 KiB
YAML
163 lines
5.7 KiB
YAML
name: "CI"
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "development"
|
|
- "public"
|
|
pull_request:
|
|
branches:
|
|
- "development"
|
|
- "public"
|
|
|
|
jobs:
|
|
setup:
|
|
name: "Setup"
|
|
runs-on: "ubuntu-latest"
|
|
outputs:
|
|
SHORT_SHA: ${{ steps.get-build-options.outputs.SHORT_SHA }}
|
|
BUILD_ARCH: ${{ steps.get-build-options.outputs.BUILD_ARCH }}
|
|
BUILD_PLATFORM: ${{ steps.get-build-options.outputs.BUILD_PLATFORM }}
|
|
HOTPOCKET_BACKEND_VERSION: ${{ steps.get-backend-version.outputs.HOTPOCKET_BACKEND_VERSION }}
|
|
HOTPOCKET_BACKEND_BUILD: ${{ steps.get-backend-version.outputs.HOTPOCKET_BACKEND_BUILD }}
|
|
steps:
|
|
- name: "Checkout the code"
|
|
uses: "actions/checkout@v2"
|
|
- name: "Get build options"
|
|
id: "get-build-options"
|
|
run: |
|
|
set -x
|
|
SHORT_SHA="${GITHUB_SHA::8}"
|
|
BUILD_ARCH="amd64"
|
|
BUILD_PLATFORM="linux/amd64"
|
|
if [ "${RUNNER_ARCH}" = "ARM64" ];then
|
|
BUILD_ARCH="arm64"
|
|
BUILD_PLATFORM="linux/arm64"
|
|
fi
|
|
echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_OUTPUT
|
|
echo "BUILD_ARCH=$BUILD_ARCH" >> $GITHUB_OUTPUT
|
|
echo "BUILD_PLATFORM=$BUILD_PLATFORM" >> $GITHUB_OUTPUT
|
|
- name: "Get `backend` version"
|
|
id: "get-backend-version"
|
|
run: |
|
|
set -x
|
|
if [ "${GITHUB_REF_NAME}" = "development" ]; then
|
|
VERSION="${GITHUB_SHA::8}"
|
|
BUILD="${GITHUB_RUN_NUMBER}"
|
|
else
|
|
VERSION="v$(grep -Po '(?<=^version\s=\s")[^"]+' services/backend/pyproject.toml)"
|
|
BUILD="01"
|
|
fi
|
|
echo "HOTPOCKET_BACKEND_VERSION=$VERSION" >> $GITHUB_OUTPUT
|
|
echo "HOTPOCKET_BACKEND_BUILD=$BUILD" >> $GITHUB_OUTPUT
|
|
|
|
run-checks:
|
|
name: "Checks"
|
|
runs-on: "ubuntu-latest"
|
|
needs:
|
|
- "setup"
|
|
steps:
|
|
- name: "Checkout the code"
|
|
uses: "actions/checkout@v2"
|
|
- name: "Set up Docker Buildx"
|
|
id: "setup-docker-buildx"
|
|
uses: "docker/setup-buildx-action@v3"
|
|
with:
|
|
driver: "remote"
|
|
endpoint: "tcp://builder-01.bthlab:2375"
|
|
platforms: "linux/amd64"
|
|
append: |
|
|
- endpoint: "tcp://builder-mac-01.bthlab:2375"
|
|
platforms: "linux/arm64"
|
|
- name: "Build `postgres` image"
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
file: "services/postgres/Dockerfile"
|
|
context: "services/"
|
|
push: false
|
|
load: true
|
|
tags: "docker-hosted.nexus.bthlabs.pl/hotpocket/postgres:15.13-local"
|
|
platforms: "${{ needs.setup.outputs.BUILD_PLATFORM }}"
|
|
- name: "Build `keycloak` image"
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
file: "services/keycloak/Dockerfile"
|
|
context: "services/"
|
|
push: false
|
|
load: true
|
|
tags: "docker-hosted.nexus.bthlabs.pl/hotpocket/keycloak:22.0.3-local"
|
|
platforms: "${{ needs.setup.outputs.BUILD_PLATFORM }}"
|
|
- name: "Build `rabbitmq` image"
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
file: "services/rabbitmq/Dockerfile"
|
|
context: "services/"
|
|
push: false
|
|
load: true
|
|
tags: "docker-hosted.nexus.bthlabs.pl/hotpocket/rabbitmq:3.10.8-local"
|
|
platforms: "${{ needs.setup.outputs.BUILD_PLATFORM }}"
|
|
- name: "Build `backend-ci` image"
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
file: "services/backend/Dockerfile"
|
|
context: "services/"
|
|
target: "ci"
|
|
push: false
|
|
load: true
|
|
tags: "docker-hosted.nexus.bthlabs.pl/hotpocket/backend:ci-local"
|
|
platforms: "${{ needs.setup.outputs.BUILD_PLATFORM }}"
|
|
- name: "Build `packages-ci` image"
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
file: "services/packages/Dockerfile"
|
|
context: "services/"
|
|
target: "ci"
|
|
push: false
|
|
load: true
|
|
tags: "docker-hosted.nexus.bthlabs.pl/hotpocket/packages:ci-local"
|
|
platforms: "${{ needs.setup.outputs.BUILD_PLATFORM }}"
|
|
- name: "Build `extension-ci` image"
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
file: "services/extension/Dockerfile"
|
|
context: "services/"
|
|
target: "ci"
|
|
push: false
|
|
load: true
|
|
tags: "docker-hosted.nexus.bthlabs.pl/hotpocket/extension:ci-local"
|
|
platforms: "${{ needs.setup.outputs.BUILD_PLATFORM }}"
|
|
- name: "Build `apple-ci` image"
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
file: "services/apple/Dockerfile"
|
|
context: "services/"
|
|
target: "ci"
|
|
push: false
|
|
load: true
|
|
tags: "docker-hosted.nexus.bthlabs.pl/hotpocket/apple:ci-local"
|
|
platforms: "${{ needs.setup.outputs.BUILD_PLATFORM }}"
|
|
- name: "Run `backend` checks"
|
|
run: |
|
|
set -x
|
|
docker compose -f docker-compose.yaml -f docker-compose-ci.yaml run --rm backend-ci inv ci
|
|
- name: "Run `packages` checks"
|
|
if: always()
|
|
run: |
|
|
set -x
|
|
docker compose -f docker-compose.yaml -f docker-compose-ci.yaml run --rm packages-ci inv ci
|
|
- name: "Run `extension` checks"
|
|
if: always()
|
|
run: |
|
|
set -x
|
|
docker compose -f docker-compose.yaml -f docker-compose-ci.yaml run --rm extension-ci inv ci
|
|
- name: "Run `apple` checks"
|
|
if: always()
|
|
run: |
|
|
set -x
|
|
docker compose -f docker-compose.yaml -f docker-compose-ci.yaml run --rm apple-ci inv ci
|
|
- name: "Clean up"
|
|
if: always()
|
|
run: |
|
|
set -x
|
|
docker compose -f docker-compose.yaml -f docker-compose-ci.yaml down --volumes
|