From bbce116ae190b8fe4665225ebe38b2dcfc1b4197 Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Mon, 7 Jun 2021 09:23:52 +0300 Subject: [PATCH] chore: run tests at GitHub Actions --- .github/workflows/go.yml | 77 ++++------- DESIGN.md | 2 - Dockerfile.ci | 12 -- Jenkinsfile | 52 ------- build/docker/aeternity_node_mean16.yaml | 4 +- build/docker/sdk.env | 4 - build/docker/wait-for-it.sh | 177 ------------------------ docker-compose.yml | 13 -- integration_test/testsetup.go | 5 +- 9 files changed, 30 insertions(+), 316 deletions(-) delete mode 100644 Dockerfile.ci delete mode 100644 Jenkinsfile delete mode 100644 build/docker/sdk.env delete mode 100755 build/docker/wait-for-it.sh diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 60819ce0..c77aa22d 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,23 +1,14 @@ -name: Go -on: - push: - tags: - - refs/tags/* +name: Test, build, and release +on: [push, pull_request] jobs: - - build: - name: Build + main: runs-on: ubuntu-latest steps: - - - name: Set up Go 1.13 - uses: actions/setup-go@v1 + - uses: actions/setup-go@v2 with: go-version: 1.13 - id: go - - name: Check out code into the Go module directory - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Get dependencies run: | @@ -25,48 +16,32 @@ jobs: if [ -f Gopkg.toml ]; then curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh dep ensure - fi + - run: go version + - run: go get github.com/tebeka/go2xunit + - run: go get -u golang.org/x/lint/golint + - run: go mod download + - run: docker-compose up -d + - run: make lint + - run: make test + - name: Build + if: true != startsWith(github.ref, 'refs/tags/') run: make build-release - - name: Create Release - id: create_release - uses: actions/create-release@v1.0.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Build release + if: startsWith(github.ref, 'refs/tags/') + run: make build-release + + - name: Publish release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} + files: | + dist/windows.zip + dist/darwin.zip + dist/linux.zip draft: true - prerelease: false - - name: Upload Release Asset - Windows - id: upload-release-asset-win - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./dist/windows.zip - asset_name: windows.zip - asset_content_type: application/zip - - name: Upload Release Asset - Mac - id: upload-release-asset-darwin - uses: actions/upload-release-asset@v1.0.1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./dist/darwin.zip - asset_name: darwin.zip - asset_content_type: application/zip - - name: Upload Release Asset - Linux - id: upload-release-asset-linux - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./dist/linux.zip - asset_name: linux.zip - asset_content_type: application/zip diff --git a/DESIGN.md b/DESIGN.md index 0240e12e..084e62fa 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -35,7 +35,5 @@ Let's start from the bottom upwards. # ensure .env has the node/compiler versions you want to test docker-compose up node compiler -export AETERNITY_ALICE_PRIVATE_KEY=..... -export AETERNITY_BOB_PRIVATE_KEY=..... go test ./integration_test -count=1 # count is needed because Go caches test results if they were successful. ``` \ No newline at end of file diff --git a/Dockerfile.ci b/Dockerfile.ci deleted file mode 100644 index 6bc03ccb..00000000 --- a/Dockerfile.ci +++ /dev/null @@ -1,12 +0,0 @@ -# Heads-Up: This Dockerfile is *exclusively* used for CI. It is referenced by -# Jenkinsfile and should not be used by any other means. - -FROM golang:1-alpine - -USER root - -RUN apk add --no-cache curl git make - -WORKDIR /go/src/app - -RUN curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index b25eda0b..00000000 --- a/Jenkinsfile +++ /dev/null @@ -1,52 +0,0 @@ -pipeline { - agent { - dockerfile { - filename 'Dockerfile.ci' - args '-v /etc/group:/etc/group:ro ' + - '-v /etc/passwd:/etc/passwd:ro ' + - '-v /var/lib/jenkins:/var/lib/jenkins ' + - '-v /usr/bin/docker:/usr/bin/docker:ro ' + - '--network=host' - } - } - - environment { - DOCKER_COMPOSE = "docker-compose -p ${env.BUILD_TAG} -H 127.0.0.1:2376" - } - - stages { - stage('Pre Test') { - steps { - sh 'go version' - sh 'go get github.com/tebeka/go2xunit' - sh 'go get -u github.com/golang/lint/golint' - sh 'go mod download' - } - } - - stage('Test') { - steps { - withCredentials([usernamePassword(credentialsId: 'genesis-wallet', - usernameVariable: 'WALLET_PUB', - passwordVariable: 'WALLET_PRIV')]) { - sh "${env.DOCKER_COMPOSE} run sdk sh -c 'make lint && make test' " - } - } - } - - stage('Build') { - steps { - sh "${env.DOCKER_COMPOSE} run sdk make build-dist" - } - } - } - } - - post { - always { - junit 'test-results.xml' - archive 'dist/*' - sh 'docker-compose -H localhost:2376 down -v ||:' - } - } -} \ No newline at end of file diff --git a/build/docker/aeternity_node_mean16.yaml b/build/docker/aeternity_node_mean16.yaml index d58f9763..d75ed78c 100644 --- a/build/docker/aeternity_node_mean16.yaml +++ b/build/docker/aeternity_node_mean16.yaml @@ -18,7 +18,7 @@ keys: dir: ./keys chain: - persist: true + persist: false hard_forks: "1": 0 "2": 2 @@ -37,4 +37,4 @@ mining: edge_bits: 15 # nice: 3 fork_management: - network_id: "ae_docker" \ No newline at end of file + network_id: "ae_docker" diff --git a/build/docker/sdk.env b/build/docker/sdk.env deleted file mode 100644 index 2c477d9d..00000000 --- a/build/docker/sdk.env +++ /dev/null @@ -1,4 +0,0 @@ -TEST_NODE=node:3013 -TEST_URL=http://node:3013 -TEST_INTERNAL_URL=http://node:3113 - diff --git a/build/docker/wait-for-it.sh b/build/docker/wait-for-it.sh deleted file mode 100755 index bbe40432..00000000 --- a/build/docker/wait-for-it.sh +++ /dev/null @@ -1,177 +0,0 @@ -#!/usr/bin/env bash -# Use this script to test if a given TCP host/port are available - -cmdname=$(basename $0) - -echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } - -usage() -{ - cat << USAGE >&2 -Usage: - $cmdname host:port [-s] [-t timeout] [-- command args] - -h HOST | --host=HOST Host or IP under test - -p PORT | --port=PORT TCP port under test - Alternatively, you specify the host and port as host:port - -s | --strict Only execute subcommand if the test succeeds - -q | --quiet Don't output any status messages - -t TIMEOUT | --timeout=TIMEOUT - Timeout in seconds, zero for no timeout - -- COMMAND ARGS Execute command with args after the test finishes -USAGE - exit 1 -} - -wait_for() -{ - if [[ $TIMEOUT -gt 0 ]]; then - echoerr "$cmdname: waiting $TIMEOUT seconds for $HOST:$PORT" - else - echoerr "$cmdname: waiting for $HOST:$PORT without a timeout" - fi - start_ts=$(date +%s) - while : - do - if [[ $ISBUSY -eq 1 ]]; then - nc -z $HOST $PORT - result=$? - else - (echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1 - result=$? - fi - if [[ $result -eq 0 ]]; then - end_ts=$(date +%s) - echoerr "$cmdname: $HOST:$PORT is available after $((end_ts - start_ts)) seconds" - break - fi - sleep 1 - done - return $result -} - -wait_for_wrapper() -{ - # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 - if [[ $QUIET -eq 1 ]]; then - timeout $BUSYTIMEFLAG $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & - else - timeout $BUSYTIMEFLAG $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & - fi - PID=$! - trap "kill -INT -$PID" INT - wait $PID - RESULT=$? - if [[ $RESULT -ne 0 ]]; then - echoerr "$cmdname: timeout occurred after waiting $TIMEOUT seconds for $HOST:$PORT" - fi - return $RESULT -} - -# process arguments -while [[ $# -gt 0 ]] -do - case "$1" in - *:* ) - hostport=(${1//:/ }) - HOST=${hostport[0]} - PORT=${hostport[1]} - shift 1 - ;; - --child) - CHILD=1 - shift 1 - ;; - -q | --quiet) - QUIET=1 - shift 1 - ;; - -s | --strict) - STRICT=1 - shift 1 - ;; - -h) - HOST="$2" - if [[ $HOST == "" ]]; then break; fi - shift 2 - ;; - --host=*) - HOST="${1#*=}" - shift 1 - ;; - -p) - PORT="$2" - if [[ $PORT == "" ]]; then break; fi - shift 2 - ;; - --port=*) - PORT="${1#*=}" - shift 1 - ;; - -t) - TIMEOUT="$2" - if [[ $TIMEOUT == "" ]]; then break; fi - shift 2 - ;; - --timeout=*) - TIMEOUT="${1#*=}" - shift 1 - ;; - --) - shift - CLI=("$@") - break - ;; - --help) - usage - ;; - *) - echoerr "Unknown argument: $1" - usage - ;; - esac -done - -if [[ "$HOST" == "" || "$PORT" == "" ]]; then - echoerr "Error: you need to provide a host and port to test." - usage -fi - -TIMEOUT=${TIMEOUT:-15} -STRICT=${STRICT:-0} -CHILD=${CHILD:-0} -QUIET=${QUIET:-0} - -# check to see if timeout is from busybox? -# check to see if timeout is from busybox? -TIMEOUT_PATH=$(realpath $(which timeout)) -if [[ $TIMEOUT_PATH =~ "busybox" ]]; then - ISBUSY=1 - BUSYTIMEFLAG="-t" -else - ISBUSY=0 - BUSYTIMEFLAG="" -fi - -if [[ $CHILD -gt 0 ]]; then - wait_for - RESULT=$? - exit $RESULT -else - if [[ $TIMEOUT -gt 0 ]]; then - wait_for_wrapper - RESULT=$? - else - wait_for - RESULT=$? - fi -fi - -if [[ $CLI != "" ]]; then - if [[ $RESULT -ne 0 && $STRICT -eq 1 ]]; then - echoerr "$cmdname: strict mode, refusing to execute subprocess" - exit $RESULT - fi - exec "${CLI[@]}" -else - exit $RESULT -fi diff --git a/docker-compose.yml b/docker-compose.yml index 443615b4..27cb430f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,18 +1,5 @@ version: '3' services: - sdk: - build: - context: . - dockerfile: Dockerfile.ci - depends_on: [node] - entrypoint: docker/wait-for-it.sh node:3013 -- - env_file: [./build/docker/sdk.env] - environment: - - WALLET_PRIV=${WALLET_PRIV} - - WALLET_PUB=${WALLET_PUB} - volumes: - - .:/go/src/app - node: image: aeternity/aeternity:${TAG} hostname: node diff --git a/integration_test/testsetup.go b/integration_test/testsetup.go index b3e26d3e..b02f87b5 100644 --- a/integration_test/testsetup.go +++ b/integration_test/testsetup.go @@ -4,7 +4,6 @@ import ( "fmt" "io/ioutil" "math/big" - "os" "testing" "time" @@ -16,8 +15,8 @@ import ( ) var sender = "ak_2a1j2Mk9YSmC1gioUq4PWRm3bsv887MbuRVwyv4KaUGoR1eiKi" -var alicePrivateKey = os.Getenv("AETERNITY_ALICE_PRIVATE_KEY") -var bobPrivateKey = os.Getenv("AETERNITY_BOB_PRIVATE_KEY") +var alicePrivateKey = "e6a91d633c77cf5771329d3354b3bcef1bc5e032c43d70b6d35af923ce1eb74dcea7ade470c9f99d9d4e400880a86f1d49bb444b62f11a9ebb64bbcfeb73fef3" +var bobPrivateKey = "7065616e38c1da983bc619188efe19bbddc8c149ddfcd3ed1c294294957a18477b47ed425587f4abd5064fe61d5a0121949a4125e8b700a2d14f0bbbafb8b2c6" var privatenetURL = "http://localhost:3013" var testnetURL = "http://sdk-testnet.aepps.com" var networkID = "ae_docker"