Previously, we would build the dokku package and install it in the same step. While the package building was relatively quick, because of our multi-architecture support, we would end up spending a large amount of time waiting for arm/arm64 images to build. This change splits those builds out, allowing unit tests to start much quicker and each platform to be tested in parallel.
242 lines
6.1 KiB
YAML
242 lines
6.1 KiB
YAML
---
|
|
name: CI
|
|
|
|
# yamllint disable-line rule:truthy
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- '*'
|
|
push:
|
|
branches:
|
|
- 'master'
|
|
|
|
concurrency:
|
|
group: build-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
check-commit:
|
|
runs-on: ubuntu-20.04
|
|
outputs:
|
|
skip: ${{ steps.check-commit.outputs.skip }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.ref }}
|
|
|
|
- name: check if message contain keywords ace scopeid
|
|
id: check-commit
|
|
run: |
|
|
# checking for "docs" or "[ci skip]" messages
|
|
message=$(git log -1 --pretty=format:'%s')
|
|
if [[ "$message" =~ "\[(ci skip)\]" ]]; then
|
|
echo "Skipping tests due to [ci skip] message"
|
|
echo "skip=true" >> $GITHUB_OUTPUT
|
|
elif [[ "$message" =~ "^docs:" ]]; then
|
|
echo "Skipping tests due to "docs:" prefix on message"
|
|
echo "skip=true" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
build:
|
|
name: build
|
|
runs-on: ubuntu-20.04
|
|
needs: check-commit
|
|
if: ${{ needs.check-commit.outputs.skip != 'true' }}
|
|
outputs:
|
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
|
strategy:
|
|
fail-fast: true
|
|
timeout-minutes: 45
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: set up qemu
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
- name: set up docker buildx
|
|
id: buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: build package
|
|
run: ./tests/ci/setup.sh build
|
|
env:
|
|
SKIP_IMAGE_BUILD: true
|
|
|
|
- name: set matrix for build
|
|
id: set-matrix
|
|
run: |
|
|
json=$(python .github/commands/matrix)
|
|
echo $json
|
|
echo "matrix=$json" >> $GITHUB_OUTPUT
|
|
|
|
- name: upload packages
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: build
|
|
path: build
|
|
|
|
build-image:
|
|
name: build-image.${{ matrix.architecture }}
|
|
needs: build
|
|
runs-on: ubuntu-20.04
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
architecture:
|
|
- linux/amd64
|
|
- linux/arm
|
|
- linux/arm64
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: download packages
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: build
|
|
path: build
|
|
|
|
- name: set up qemu
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
- name: set up docker buildx
|
|
id: buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: build docker image
|
|
run: |
|
|
docker buildx build \
|
|
--platform ${{ matrix.architecture }} \
|
|
--progress plain \
|
|
--tag "dokku/dokku:latest"
|
|
|
|
unit-tests:
|
|
name: unit.${{ matrix.index }}
|
|
needs: build
|
|
runs-on: ubuntu-20.04
|
|
strategy:
|
|
fail-fast: false
|
|
matrix: ${{fromJson(needs.build.outputs.matrix)}}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: download packages
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: build
|
|
path: build
|
|
|
|
- name: ci-setup
|
|
run: ./.github/commands/ci-setup
|
|
|
|
# - name: start ssh session
|
|
# uses: luchihoratiu/debug-via-ssh@main
|
|
# with:
|
|
# NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
|
|
# SSH_PASS: ${{ secrets.SSH_PASS }}
|
|
|
|
- name: run ci
|
|
timeout-minutes: 30
|
|
run: sudo -E ./.github/commands/ci-run ${{ matrix.index }}
|
|
env:
|
|
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
SYNC_GITHUB_PASSWORD: ${{ secrets.SYNC_GITHUB_PASSWORD }}
|
|
SYNC_GITHUB_USERNAME: ${{ secrets.SYNC_GITHUB_USERNAME }}
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: test-results-${{ matrix.index }}
|
|
path: test-results
|
|
|
|
docker-deploy-tests:
|
|
name: docker
|
|
needs: build
|
|
runs-on: ubuntu-20.04
|
|
strategy:
|
|
fail-fast: false
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: download packages
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: build
|
|
path: build
|
|
|
|
- name: ci-setup
|
|
run: ./.github/commands/ci-setup
|
|
|
|
- name: test docker deploys
|
|
shell: bash
|
|
timeout-minutes: 20
|
|
run: |
|
|
./tests/ci/setup.sh docker
|
|
DOKKU_SSH_PORT=3022 sudo -E make -e test-ci-docker
|
|
|
|
go-tests:
|
|
name: go.${{ matrix.index }}
|
|
needs: build
|
|
runs-on: ubuntu-20.04
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
index: [0, 1, 2, 3]
|
|
env:
|
|
GITHUB_NODE_INDEX: ${{ matrix.index }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: download packages
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: build
|
|
path: build
|
|
|
|
- name: ci-setup
|
|
run: ./.github/commands/ci-setup
|
|
|
|
- name: run go tests
|
|
run: |
|
|
export CIRCLE_SHA1=$GITHUB_SHA
|
|
echo "CODACY_TOKEN=$CODACY_TOKEN"
|
|
if [ "$CODACY_TOKEN" != "" ]; then
|
|
echo "Detected value for CODACY_TOKEN"
|
|
fi
|
|
case $GITHUB_NODE_INDEX in
|
|
0) sudo -E make -e lint-ci go-tests ci-go-coverage ;;
|
|
1) sudo -E make -e deploy-test-checks-root deploy-test-config ;;
|
|
2) sudo -E make -e deploy-test-multi ;;
|
|
3) sudo -E make -e deploy-test-go-fail-predeploy deploy-test-go-fail-postdeploy ;;
|
|
esac
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: coverage.${{ matrix.index }}
|
|
path: test-results/coverage
|
|
|
|
publish-test-results:
|
|
name: publish-test-results
|
|
needs: unit-tests
|
|
runs-on: ubuntu-20.04
|
|
# the build-and-test job might be skipped, we don't need to run this job then
|
|
if: success() || failure()
|
|
|
|
steps:
|
|
- name: download test-results
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
path: test-results
|
|
|
|
- name: Publish Unit Test Results
|
|
uses: EnricoMi/publish-unit-test-result-action@v2
|
|
with:
|
|
check_name: Unit Test Results
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
junit_files: test-results/**/*.xml
|
|
comment_mode: "off"
|