Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #2940 from fluxcd/ci-github-actions
Browse files Browse the repository at this point in the history
ci: Migrate tests to GitHub actions
  • Loading branch information
stefanprodan authored Mar 30, 2020
2 parents ea6d699 + 61b5ce8 commit fae1d81
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 8 deletions.
4 changes: 0 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,7 @@ jobs:
keys:
- go-mod-{{ checksum "go.mod" }}
- go-mod-
# Note that the test timeout is per Go package
- run: make test TEST_FLAGS="-race -tags integration -timeout 5m"
- run: make check-generated
- run: make all
- run: E2E_KIND_CLUSTER_NUM=4 make e2e
- save_cache:
key: cache-{{ checksum "Makefile" }}
paths:
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/ci-cleanup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: artifacts-cleanup

on:
schedule:
# Every day at 1am
- cron: '0 1 * * *'

jobs:
remove-old-artifacts:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Remove old artifacts
uses: c-hive/gha-remove-artifacts@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
age: '1 day'
skip-tags: false
73 changes: 73 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: ci

on:
pull_request:
push:
branches:
- master

jobs:
unit-testing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: niden/actions-memcached@v7
- name: Restore Go cache
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Setup Go
uses: actions/setup-go@v2-beta
with:
go-version: 1.14.x
- name: Run tests
run: make test TEST_FLAGS="-race -tags integration -timeout 5m"
- name: Check codegen
run: make check-generated
- name: Build binaries
run: make all
- name: Prepare cache
run: |
cp "$(go env GOPATH)/bin/fluxctl" cache/fluxctl
docker save -o cache/flux-latest.tar fluxcd/flux:latest
- name: Upload cache
uses: actions/upload-artifact@v1
with:
name: cache
path: cache
e2e-testing:
runs-on: ubuntu-latest
needs: unit-testing
strategy:
matrix:
test: ['10_* 11_* 12_*', '13_* 14_*', '15_* 16_* 17_*', '20_* 21_* 22_*']
steps:
- uses: actions/checkout@v2
- uses: engineerd/[email protected]
- name: Restore Go cache
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Setup Go
uses: actions/setup-go@v2-beta
with:
go-version: 1.14.x
- name: Download cache
uses: actions/download-artifact@v1
with:
name: cache
- name: Load cache
run: |
chmod +x cache/fluxctl
sudo mv cache/fluxctl /usr/local/bin/fluxctl
docker load --input cache/flux-latest.tar -q
kind load docker-image fluxcd/flux:latest
- name: Run tests
run: |
E2E_TESTS='${{ matrix.test }}' make e2e-gh
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
on: [push, pull_request]
name: Check links
name: docs

on:
pull_request:
push:
branches:
- master

jobs:
linkChecker:
link-checker:
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ BUILD_DATE:=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')

GENERATED_TEMPLATES_FILE=pkg/install/generated_templates.gogen.go

all: $(GOBIN)/fluxctl $(GOBIN)/fluxd build/.flux.done
all: $(GOBIN)/fluxctl build/.flux.done

release-bins: $(GENERATED_TEMPLATES_FILE)
for arch in amd64; do \
Expand Down Expand Up @@ -65,6 +65,9 @@ test: test/bin/helm test/bin/kubectl test/bin/sops test/bin/kustomize $(GENERATE
e2e: lint-e2e test/bin/helm test/bin/kubectl test/bin/sops test/bin/crane test/e2e/bats $(GOBIN)/fluxctl build/.flux.done
PATH="${PWD}/test/bin:${PATH}" CURRENT_OS_ARCH=$(CURRENT_OS_ARCH) test/e2e/run.bash

e2e-gh: lint-e2e test/bin/helm test/bin/kubectl test/bin/sops test/bin/crane test/e2e/bats
PATH="${PWD}/test/bin:${PATH}" CURRENT_OS_ARCH=$(CURRENT_OS_ARCH) test/e2e/run-gh.bash

E2E_BATS_FILES := test/e2e/*.bats
E2E_BASH_FILES := test/e2e/run.bash test/e2e/lib/*
SHFMT_DIFF_CMD := test/bin/shfmt -i 2 -sr -d
Expand Down
10 changes: 10 additions & 0 deletions test/e2e/fixtures/kustom/base/gitsrv/gitsrv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ spec:
- containerPort: 22
name: ssh
protocol: TCP
readinessProbe:
tcpSocket:
port: 22
initialDelaySeconds: 20
periodSeconds: 10
livenessProbe:
tcpSocket:
port: 22
initialDelaySeconds: 20
periodSeconds: 10
volumeMounts:
- mountPath: /git-server/repos
name: git-server-data
Expand Down
33 changes: 33 additions & 0 deletions test/e2e/run-gh.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

set -o errexit

# This script runs the bats tests

# Directory paths we need to be aware of
FLUX_ROOT_DIR="$(git rev-parse --show-toplevel)"
E2E_DIR="${FLUX_ROOT_DIR}/test/e2e"
CACHE_DIR="${FLUX_ROOT_DIR}/cache/$CURRENT_OS_ARCH"

KIND_VERSION=v0.7.0
KUBE_VERSION=v1.14.10
GITSRV_VERSION=v1.0.0
KIND_CACHE_PATH="${CACHE_DIR}/kind-$KIND_VERSION"
KIND_CLUSTER_PREFIX=flux-e2e
BATS_EXTRA_ARGS=""

# shellcheck disable=SC1090
source "${E2E_DIR}/lib/defer.bash"
trap run_deferred EXIT

mkdir -p "${FLUX_ROOT_DIR}/cache"
curl -sL "https://github.com/fluxcd/gitsrv/releases/download/${GITSRV_VERSION}/known_hosts.txt" > "${FLUX_ROOT_DIR}/cache/known_hosts"

echo '>>> Running the tests'
# Run all tests by default but let users specify which ones to run, e.g. with E2E_TESTS='11_*' make e2e
E2E_TESTS=${E2E_TESTS:-.}
(
cd "${E2E_DIR}"
# shellcheck disable=SC2086
"${E2E_DIR}/bats/bin/bats" -t ${BATS_EXTRA_ARGS} ${E2E_TESTS}
)

0 comments on commit fae1d81

Please sign in to comment.