Skip to content

Commit

Permalink
ci: try using gha
Browse files Browse the repository at this point in the history
Signed-off-by: Tiago Castro <[email protected]>
  • Loading branch information
tiagolobocastro committed Dec 24, 2024
1 parent 776f7f0 commit 84af077
Show file tree
Hide file tree
Showing 11 changed files with 284 additions and 22 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/bdd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: BDD CI
on:
workflow_call:

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0

jobs:
bdd-tests:
runs-on: ubuntu-latest-16-cores
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
- uses: DeterminateSystems/nix-installer-action@v14
- uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Pre-populate nix-shell
run: |
export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r)
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
nix-shell --run "echo" shell.nix
- name: Handle Rust dependencies caching
uses: Swatinem/rust-cache@v2
- name: Build binaries
run: nix-shell --run "cargo build --bins"
- name: Setup Test Pre-Requisites
run: |
sudo sysctl -w vm.nr_hugepages=3072
sudo apt-get install linux-modules-extra-$(uname -r)
sudo modprobe nvme_tcp
- name: Run BDD Tests
run: |
nix-shell --run "deployer start --image-pull-policy always -w 60s && deployer stop"
nix-shell --run "./scripts/python/test.sh"
- name: Cleanup
if: always()
run: nix-shell --run "./scripts/python/test-residue-cleanup.sh"
- name: Surface failing tests
if: always()
uses: pmeier/pytest-results-action@main
with:
path: report.xml
summary: true
display-options: a
fail-on-empty: true
title: Test results
# debugging
# - name: Setup tmate session
# if: ${{ failure() }}
# timeout-minutes: 120
# uses: mxschmitt/action-tmate@v3
31 changes: 31 additions & 0 deletions .github/workflows/helm-chart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Helm Chart CI
on:
workflow_call:
pull_request:
types: ['opened', 'edited', 'reopened', 'synchronize']

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0

jobs:
helm-chart-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- uses: DeterminateSystems/nix-installer-action@v14
- uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Pre-populate nix-shell
run: |
export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r)
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
nix-shell --run "echo" ./scripts/helm/shell.nix
- name: HelmChart publish test
run: |
nix-shell --pure --run "./scripts/helm/test-publish-chart-yaml.sh" ./scripts/helm/shell.nix
- name: HelmChart Readme
run: nix-shell --run "./scripts/helm/generate-readme.sh" ./scripts/helm/shell.nix
- name: HelmChart Template
run: nix-shell --pure --run "./scripts/helm/test-template.sh" ./scripts/helm/shell.nix
19 changes: 19 additions & 0 deletions .github/workflows/image-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: ImageBuild CI
on:
workflow_call:

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0

jobs:
image-build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- uses: DeterminateSystems/nix-installer-action@v14
- uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Test building the release images
run: ./scripts/release.sh --skip-publish --build-bins
24 changes: 24 additions & 0 deletions .github/workflows/image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Image Push
on:
push:
branches:
- develop
- 'release/**'
tags:
- 'v[0-9]+.[0-9]+.[0-9]+**'

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0

jobs:
image-build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- uses: DeterminateSystems/nix-installer-action@v14
- uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Test building the release images
run: ./scripts/release.sh
1 change: 1 addition & 0 deletions .github/workflows/k8s-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: K8s CI
on:
pull_request:
types: ['opened', 'edited', 'reopened', 'synchronize']
workflow_call:

jobs:
k8s-ci:
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Unit/Int CI
on:
workflow_call:

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0

jobs:
linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- uses: DeterminateSystems/nix-installer-action@v14
- uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Pre-populate nix-shell
run: |
export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r)
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
nix-shell --run "echo" shell.nix
- name: Handle Rust dependencies caching
uses: Swatinem/rust-cache@v2
- name: Lint rust code
run: |
nix-shell --run "./dependencies/control-plane/scripts/rust/generate-openapi-bindings.sh"
nix-shell --run "./scripts/rust/linter.sh"
- name: Check submodules
run: nix-shell --run "./scripts/git/check-submodule-branches.sh"
24 changes: 24 additions & 0 deletions .github/workflows/nightly-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Nightly CI
on:
workflow_dispatch:

jobs:
lint-ci:
uses: ./.github/workflows/lint.yml
int-ci:
uses: ./.github/workflows/unit-int.yml
bdd-ci:
uses: ./.github/workflows/bdd.yml
image-ci:
uses: ./.github/workflows/image-pr.yml
bors-ci:
if: ${{ success() }}
needs:
- lint-ci
- int-ci
- bdd-ci
- image-ci
runs-on: ubuntu-latest
steps:
- name: CI succeeded
run: exit 0
34 changes: 34 additions & 0 deletions .github/workflows/pr-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Bors CI
on:
push:
branches:
- staging
- trying
- ci

jobs:
lint-ci:
uses: ./.github/workflows/lint.yml
helm-ci:
uses: ./.github/workflows/helm-chart.yml
int-ci:
uses: ./.github/workflows/unit-int.yml
bdd-ci:
uses: ./.github/workflows/bdd.yml
image-ci:
uses: ./.github/workflows/image-pr.yml
k8s-ci:
uses: ./.github/workflows/k8s-ci.yml
bors-ci:
if: ${{ success() }}
needs:
- lint-ci
- helm-ci
- int-ci
- bdd-ci
- image-ci
- k8s-ci
runs-on: ubuntu-latest
steps:
- name: CI succeeded
run: exit 0
22 changes: 0 additions & 22 deletions .github/workflows/template-chart.yml

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/unit-int.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Integration CI
on:
workflow_call:

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0

jobs:
int-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
- uses: DeterminateSystems/nix-installer-action@v14
- uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Pre-populate nix-shell
run: |
export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r)
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
nix-shell --run "echo" shell.nix
- name: Handle Rust dependencies caching
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ startsWith(github.ref_name, 'release/') || github.ref_name == 'develop' || github.ref_name == 'ci' }}
- name: Build the binaries
run: nix-shell --run "cargo build --bins"
- name: Build the tests
run: nix-shell --run "./scripts/rust/test.sh --no-run"
- name: Run Tests
run: |
# includes both unit and integration tests
nix-shell --run "./scripts/rust/test.sh"
# debugging
# - name: Setup tmate session
# if: ${{ failure() }}
# timeout-minutes: 120
# uses: mxschmitt/action-tmate@v3
28 changes: 28 additions & 0 deletions scripts/rust/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

SCRIPT_DIR="$(dirname "$0")"

ARGS=""
OPTS=""
DO_ARGS=
while [ "$#" -gt 0 ]; do
case $1 in
--)
DO_ARGS="y"
shift;;
*)
if [ "$DO_ARGS" == "y" ]; then
ARGS="$ARGS $1"
else
OPTS="$OPTS $1"
fi
shift;;
esac
done

set -euxo pipefail

# build test dependencies
cargo build --bins

cargo test ${OPTS} -- ${ARGS} --test-threads=1

0 comments on commit 84af077

Please sign in to comment.