mirror of
https://github.com/outbackdingo/cozystack.git
synced 2026-03-20 21:41:15 +00:00
This patch separates the Test job of the PR workflow into several smaller jobs: 1) create a testing sandbox and deploy Talos, 2) install Cozystack and configure it, 3) install managed applications and run e2e tests. This lets developers shorten the feedback loop if tests are merely acting flaky and aren't really broken. It's not the right way, but it's 80/20. Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
158 lines
4.3 KiB
YAML
158 lines
4.3 KiB
YAML
name: Pull Request
|
|
|
|
on:
|
|
pull_request:
|
|
types: [labeled, opened, synchronize, reopened]
|
|
|
|
concurrency:
|
|
group: pull-requests-${{ github.workflow }}-${{ github.event.pull_request.number }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build:
|
|
name: Build
|
|
runs-on: [self-hosted]
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
# Never run when the PR carries the "release" label.
|
|
if: |
|
|
!contains(github.event.pull_request.labels.*.name, 'release')
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
registry: ghcr.io
|
|
env:
|
|
DOCKER_CONFIG: ${{ runner.temp }}/.docker
|
|
|
|
- name: Build
|
|
run: make build
|
|
env:
|
|
DOCKER_CONFIG: ${{ runner.temp }}/.docker
|
|
|
|
- name: Build Talos image
|
|
run: make -C packages/core/installer talos-nocloud
|
|
|
|
- name: Upload installer
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: cozystack-installer
|
|
path: _out/assets/cozystack-installer.yaml
|
|
|
|
- name: Upload Talos image
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: talos-image
|
|
path: _out/assets/nocloud-amd64.raw.xz
|
|
|
|
prepare_env:
|
|
name: Prepare environment
|
|
runs-on: [self-hosted]
|
|
needs: build
|
|
|
|
# Never run when the PR carries the "release" label.
|
|
if: |
|
|
!contains(github.event.pull_request.labels.*.name, 'release')
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
|
|
- name: Download installer
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: cozystack-installer
|
|
path: _out/assets/
|
|
|
|
- name: Download Talos image
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: talos-image
|
|
path: _out/assets/
|
|
|
|
- name: Set sandbox ID
|
|
run: echo "SANDBOX_NAME=cozy-e2e-sandbox-$(echo "${GITHUB_REPOSITORY}:${GITHUB_WORKFLOW}:${GITHUB_REF}" | sha256sum | cut -c1-10)" >> $GITHUB_ENV
|
|
|
|
- name: Prepare environment
|
|
run: make SANDBOX_NAME=$SANDBOX_NAME prepare-env
|
|
|
|
install_cozystack:
|
|
name: Install Cozystack
|
|
runs-on: [self-hosted]
|
|
needs: prepare_env
|
|
|
|
# Never run when the PR carries the "release" label.
|
|
if: |
|
|
!contains(github.event.pull_request.labels.*.name, 'release')
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
|
|
- name: Set sandbox ID
|
|
run: echo "SANDBOX_NAME=cozy-e2e-sandbox-$(echo "${GITHUB_REPOSITORY}:${GITHUB_WORKFLOW}:${GITHUB_REF}" | sha256sum | cut -c1-10)" >> $GITHUB_ENV
|
|
|
|
- name: Install Cozystack
|
|
run: make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME install-cozystack
|
|
|
|
test_apps:
|
|
name: Test applications
|
|
runs-on: [self-hosted]
|
|
needs: install_cozystack
|
|
|
|
# Never run when the PR carries the "release" label.
|
|
if: |
|
|
!contains(github.event.pull_request.labels.*.name, 'release')
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
|
|
- name: Set sandbox ID
|
|
run: echo "SANDBOX_NAME=cozy-e2e-sandbox-$(echo "${GITHUB_REPOSITORY}:${GITHUB_WORKFLOW}:${GITHUB_REF}" | sha256sum | cut -c1-10)" >> $GITHUB_ENV
|
|
|
|
- name: E2E Apps
|
|
run: make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME test-apps
|
|
|
|
cleanup:
|
|
name: Tear down environment
|
|
runs-on: [self-hosted]
|
|
needs: test_apps
|
|
|
|
# Never run when the PR carries the "release" label.
|
|
if: |
|
|
!contains(github.event.pull_request.labels.*.name, 'release')
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
|
|
- name: Set sandbox ID
|
|
run: echo "SANDBOX_NAME=cozy-e2e-sandbox-$(echo "${GITHUB_REPOSITORY}:${GITHUB_WORKFLOW}:${GITHUB_REF}" | sha256sum | cut -c1-10)" >> $GITHUB_ENV
|
|
|
|
- name: E2E Apps
|
|
run: make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME delete
|