Skip to content

Commit

Permalink
tests: use github actions instead of circleci for test running
Browse files Browse the repository at this point in the history
  • Loading branch information
josegonzalez committed Jan 20, 2021
1 parent 3c5a3fd commit a7465f9
Show file tree
Hide file tree
Showing 16 changed files with 438 additions and 297 deletions.
115 changes: 6 additions & 109 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,116 +1,13 @@
version: 2.1

commands:
init-tests:
description: "Setup dokku for testing"
steps:
- checkout
- attach_workspace:
at: /home/circleci/project
- run:
name: resolve dokku.me
command: |
# dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to ens4
# this is maybe eth0 on github
ifconfig
sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev ens4
- run:
name: install ci-dependencies
command: make ci-dependencies
- run:
name: setup tests
command: ./tests/ci/setup.sh
- run:
name: dokku cleanup:skip
command: echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup
- run:
name: dokku report
command: dokku report

executors:
default:
machine:
image: ubuntu-1604:201903-01
working_directory: /home/circleci/project

jobs:
build:
executor: default
steps:
- checkout
- run:
name: build package
command: ./tests/ci/setup.sh build
- persist_to_workspace:
root: /home/circleci/project
paths:
- build
- store_artifacts:
path: /home/circleci/project/build/dokku.deb
- store_artifacts:
path: /home/circleci/project/build/dokku.rpm
docker-deploy-tests:
executor: default
steps:
- init-tests
- run:
name: run docker deploy tests
shell: /bin/bash
no_output_timeout: 20
command: |
./tests/ci/setup.sh docker
DOKKU_SSH_PORT=3022 sudo -E make -e test-ci-docker
go-tests:
executor: default
parallelism: 4
steps:
- init-tests
- run:
name: run go tests
command: |
case $CIRCLE_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
- store_artifacts:
path: ./coverage.out
test:
executor: default
parallelism: 4
noop:
docker:
- image: cimg/base:2020.01
steps:
- init-tests
- run:
name: run bats tests
command: |
if ! sudo -E make -e test-ci; then
sudo -E make tests-ci-retry-failed
fi
no_output_timeout: 60m
shell: /bin/bash
- run:
name: output oomkills
command: cat /var/log/syslog
when: on_fail
- store_artifacts:
path: ./test-results
destination: test-results
- store_test_results:
path: test-results
- run: echo "this is a noop"

workflows:
workflow:
noop:
jobs:
- build
- docker-deploy-tests:
requires:
- build
- test
- go-tests:
requires:
- build
- test:
requires:
- build
- go-tests
- noop
15 changes: 15 additions & 0 deletions .github/commands/ci-run
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -eo pipefail

main() {
declare FILE_NAME="$1"

mkdir -p test-results/bats
pushd tests/unit >/dev/null
bats --report-formatter junit --output ../../test-results/bats "$FILE_NAME.bats"
popd >/dev/null

ls -lah test-results/bats
}

main "$@"
20 changes: 20 additions & 0 deletions .github/commands/ci-setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -eo pipefail

echo "=====> resolve dokku.me"
sudo apt -qq -y --no-install-recommends install net-tools
# dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to eth0
ifconfig
sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev eth0

echo "=====> install ci-dependencies"
make ci-dependencies

echo "=====> setup tests"
./tests/ci/setup.sh

echo "=====> dokku cleanup:skip"
echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup

echo "=====> dokku report"
dokku report
9 changes: 9 additions & 0 deletions .github/commands/matrix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env python
import json
import os

keys = ["index"]
values = [[s.replace(".bats", "") for s in os.listdir("tests/unit/") if s.endswith(".bats")]]
zi = zip(keys, values)
data = json.dumps(dict(zi))
print(data.replace(" ", ""))
157 changes: 157 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: CI

on:
pull_request:
branches:
- '*'
push:
branches:
- 'master'

jobs:
build:
name: build
runs-on: ubuntu-16.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
strategy:
fail-fast: true

steps:
- uses: actions/checkout@v2

- name: build package
run: ./tests/ci/setup.sh build

- name: set matrix for build
id: set-matrix
run: |
json=$(python .github/commands/matrix)
echo $json
echo "::set-output name=matrix::$(echo "$json")"
- name: upload packages
uses: actions/upload-artifact@v2
with:
name: build
path: build

unit-tests:
name: unit.${{ matrix.index }}
needs: build
runs-on: ubuntu-16.04
strategy:
fail-fast: false
matrix: ${{fromJson(needs.build.outputs.matrix)}}

steps:
- uses: actions/checkout@v2

- name: download packages
uses: actions/download-artifact@v1
with:
name: 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 }}

- uses: actions/upload-artifact@v2
with:
name: test-results-${{ matrix.index }}
path: test-results

docker-deploy-tests:
name: docker
needs: build
runs-on: ubuntu-16.04
strategy:
fail-fast: false

steps:
- uses: actions/checkout@v2

- name: download packages
uses: actions/download-artifact@v1
with:
name: 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-16.04
strategy:
fail-fast: false
matrix:
index: [0, 1, 2, 3]
env:
GITHUB_NODE_INDEX: ${{ matrix.index }}

steps:
- uses: actions/checkout@v2

- name: download packages
uses: actions/download-artifact@v1
with:
name: 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@v2
with:
name: coverage.${{ matrix.index }}
path: test-results/coverage

publish-test-results:
name: publish-test-results
needs: unit-tests
runs-on: ubuntu-16.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@v2
with:
path: test-results

- name: Publish Unit Test Results
uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1.6
with:
check_name: Unit Test Results
github_token: ${{ secrets.GITHUB_TOKEN }}
files: test-results/**/*.xml
comment_on_pr: false
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN echo "dokku dokku/hostname string $DOKKU_HOSTNAME" | debconf-set-selections
&& cp /tmp/dhparam.pem /etc/nginx/dhparam.pem \
&& apt-get update -qq \
&& apt-get upgrade -qq -y \
&& apt-get -qq -y --no-install-recommends install --only-upgrade openssl openssh-server \
&& apt-get -qq -y --no-install-recommends --only-upgrade install openssl openssh-server \
&& apt-get -qq -y --no-install-recommends install rsync /tmp/dokku.deb \
&& apt-get purge -qq -y syslog-ng-core \
&& apt-get autoremove -qq -y \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Dokku
[![Build Status](https://img.shields.io/circleci/project/github/dokku/dokku.svg?style=flat-square "Build Status")](https://circleci.com/gh/dokku/dokku/tree/master)
[![Build Status](https://github.com/dokku/dokku/workflows/CI/badge.svg)](https://github.com/dokku/dokku/actions?query=workflow%3ACI)
[![Ubuntu Package](https://img.shields.io/badge/package-ubuntu-brightgreen.svg?style=flat-square "Ubuntu Package")](https://packagecloud.io/dokku/dokku)
[![Arch Package](https://img.shields.io/badge/package-arch-brightgreen.svg?style=flat-square "Arch Package")](https://aur.archlinux.org/packages/dokku/)
[![IRC Network](https://img.shields.io/badge/irc-freenode-blue.svg?style=flat-square "IRC Freenode")](https://webchat.freenode.net/?channels=dokku)
Expand Down
5 changes: 4 additions & 1 deletion common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ GO_ARGS ?=
GO_PLUGIN_MAKE_TARGET ?= build
GO_REPO_ROOT := /go/src/github.com/dokku/dokku
BUILD_IMAGE := golang:1.15.6
GO_BUILD_CACHE ?= /tmp/dokku-go-build-cache
GO_MOD_CACHE ?= /tmp/dokku-go-mod-mod

.PHONY: build-in-docker build clean src-clean

Expand All @@ -11,7 +13,8 @@ build-in-docker: clean
mkdir -p /tmp/dokku-go-build-cache
docker run --rm \
-v $$PWD/../..:$(GO_REPO_ROOT) \
-v /tmp/dokku-go-build-cache:/root/.cache \
-v $(GO_BUILD_CACHE):/root/.cache \
-v $(GO_MOD_CACHE):/go/pkg/mod \
-e PLUGIN_NAME=$(PLUGIN_NAME) \
-e GO111MODULE=on \
-w $(GO_REPO_ROOT)/plugins/$(PLUGIN_NAME) \
Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ If Dokku was installed in a Debian or Ubuntu system, via `apt-get install dokku`
```shell
# update your local apt cache
sudo apt-get update
sudo apt-get update -qq
# update dokku and its dependencies
sudo apt-get -qq -y install dokku herokuish sshcommand plugn gliderlabs-sigil
sudo apt-get -qq -y --no-install-recommends install dokku herokuish sshcommand plugn gliderlabs-sigil dokku-update dokku-event-listener
# or just upgrade every package:
sudo apt-get upgrade
Expand Down
3 changes: 1 addition & 2 deletions plugins/nginx-vhosts/dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ trigger-nginx-vhosts-dependencies() {
[[ "$ubuntu_year" -ge "16" ]] && exit 0
[[ "$ubuntu_year" -eq "15" ]] && [[ "$ubuntu_month" -eq "10" ]] && exit 0

[[ -z "$CIRCLECI" ]] && apt-get -qq -y --no-install-recommends install software-properties-common python-software-properties
[[ -n "$CIRCLECI" ]] && aptitude install -q -y software-properties-common python-software-properties
apt-get -qq -y --no-install-recommends install software-properties-common python-software-properties

add-apt-repository -y ppa:nginx/stable
apt-get update -qq >/dev/null
Expand Down
Loading

0 comments on commit a7465f9

Please sign in to comment.