From ee5d881ad30c17b486a0a976ac909418d4f3f607 Mon Sep 17 00:00:00 2001 From: kiloreux Date: Tue, 1 Oct 2019 16:58:22 +0100 Subject: [PATCH] ci: Move from Travis to GitHub Actions (#308) * Initial commit * trimpath error * Test * test priority * Another versiong * ON push only * Build also * Enable GO11MODULE * Disable trimpath * Separate jobs * Change stuff * Matrix build again * Remove mapping * Don't use script * Disable version temp * Restore * Deploy on master only * Deploy on master push * Remove unused code * Rename GitHub token secret The GITHUB_ prefix is reserved (see https://help.github.com/en/articles/virtual-environments-for-github-actions#naming-conventions) and I was not able to create a secret called GITHUB_TOKEN --- .github/workflows/main.yml | 58 ++++++++++++++++++++++++++++++++++++++ .travis.yml | 44 ----------------------------- appveyor.yml | 14 --------- scripts/deploy_kube.sh | 45 ----------------------------- scripts/test_all.sh | 6 ---- 5 files changed, 58 insertions(+), 109 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100644 .travis.yml delete mode 100644 appveyor.yml delete mode 100755 scripts/deploy_kube.sh delete mode 100755 scripts/test_all.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..902325d --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,58 @@ +on: [push] +name: Test +jobs: + test: + strategy: + matrix: + go-version: [1.12.x, 1.13.x] + platform: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.platform }} + steps: + - name: Install Matrix Go + uses: actions/setup-go@v1 + with: + go-version: ${{ matrix.go-version }} + - name: Checkout code + uses: actions/checkout@v1 + - name: Test code + env: + GO111MODULE: on + run: | + go test ./pkg/... + go vet ./pkg/... + build: + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/master' + steps: + - name: Install Go 1.13.1 + uses: actions/setup-go@v1 + with: + go-version: '1.13.1' + - name: Checkout code + uses: actions/checkout@v1 + - name: Build TUSD + env: + GO111MODULE: on + run: ./scripts/build_all.sh + - uses: azure/container-actions/docker-login@master + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build and push docker image + run: | + docker build -t tusproject/tusd:$GITHUB_SHA . + docker push tusproject/tusd:$GITHUB_SHA + - name: Deploy to cluster + uses: steebchen/kubectl@master + env: + KUBE_CONFIG_DATA: | + ${{ secrets.KUBECONFIG }} + with: + args: set image --record deployment/tusd tusd=tusproject/tusd:$GITHUB_SHA -n tus + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: tusd_*.* + env: + GITHUB_TOKEN: ${{ secrets.GH_RELEASE_TOKEN }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 91f0a75..0000000 --- a/.travis.yml +++ /dev/null @@ -1,44 +0,0 @@ -language: go -go: -- 1.12 -- 1.13 -env: -- GO111MODULE=on -os: -- linux -- windows -sudo: required -addons: - apt: - packages: - - docker-ce -cache: - apt: true - directories: - - $HOME/.gimme - - "$HOME/google-cloud-sdk/" -install: -- true -script: -- ./scripts/test_all.sh -before_deploy: -- if [[ "$TRAVIS_TAG" != "" ]]; then ./scripts/build_all.sh; fi -deploy: -- provider: releases - api_key: - secure: dV3wr9ebEps3YrzIoqmkYc7fw0IECz7QLPRENPSxTJyd5TTYXGsnTS26cMe2LdGwYrXw0njt2GGovMyBZFTtxyYI3mMO4AZRwvZfx/yGzPWJBbVi6NjZVRg/bpyK+mQJ5BUlkPAYJmRpdc6qD+nvCGakBOxoByC5XDK+yM+bKFs= - file_glob: true - file: tusd_*.* - skip_cleanup: true - on: - tags: true - go: 1.13 - repo: tus/tusd - condition: $TRAVIS_OS_NAME = linux -- provider: script - script: scripts/deploy_kube.sh - on: - branch: master - go: 1.13 - repo: tus/tusd - condition: $TRAVIS_OS_NAME = linux diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 5e77750..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,14 +0,0 @@ -clone_folder: c:\projects\go\src\github.com\tus\tusd - -environment: - GOPATH: c:\projects\go - GO111MODULE: on - -build_script: - - set PATH=%GOPATH%\bin;%PATH% - - go env - - go version - -test_script: - - go test ./pkg/... - - go vet ./pkg/... diff --git a/scripts/deploy_kube.sh b/scripts/deploy_kube.sh deleted file mode 100755 index 6a6e0e7..0000000 --- a/scripts/deploy_kube.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env bash -set -o pipefail -set -o errexit -set -o nounset -# set -o xtrace - -# Set magic variables for current FILE & DIR -__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -__root="$(cd "$(dirname "${__dir}")" && pwd)" - -curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl -chmod +x ./kubectl -sudo mv ./kubectl /usr/local/bin/kubectl - -#Store the new image in docker hub -docker build --quiet -t tusproject/tusd:latest -t tusproject/tusd:$TRAVIS_COMMIT ${__root}; -docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"; -docker push tusproject/tusd:$TRAVIS_COMMIT; -docker push tusproject/tusd:latest; - - -echo "Create directory..." -mkdir ${HOME}/.kube -echo "Writing KUBECONFIG to file..." -echo $KUBECONFIGVAR | python -m base64 -d > ${HOME}/.kube/config -echo "KUBECONFIG file written" - -sleep 10s # This cost me some precious debugging time. -kubectl apply -f "${__root}/infra/kube/tusd-kube.yaml" - - -kubectl set image deployment/tusd --namespace=tus tusd=docker.io/tusproject/tusd:$TRAVIS_COMMIT - -kubectl get pods --namespace=tus -kubectl get service --namespace=tus -kubectl get deployment --namespace=tus - - -function cleanup { - printf "Cleaning up...\n" - rm -f ${HOME}/.kube/config - printf "Cleaning done." -} - -trap cleanup EXIT diff --git a/scripts/test_all.sh b/scripts/test_all.sh deleted file mode 100755 index b47d896..0000000 --- a/scripts/test_all.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -set -e - -go test ./pkg/... -go vet ./pkg/...