From c4c8fe81cc9af83eccf6029e8432d0ec75998e46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Serv=C3=A9n=20Mar=C3=ADn?= Date: Sat, 30 Jan 2021 21:26:46 +0100 Subject: [PATCH] .github/workflows: migrate to github actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lucas Servén Marín --- .github/workflows/ci.yml | 140 +++++++++++++++++++++++++++++++++++++++ .travis.yml | 34 ---------- Makefile | 4 +- README.md | 2 +- go.mod | 2 +- 5 files changed, 144 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..bbf189d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,140 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + schedule: + - cron: '0 0 * * *' + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15.7 + - name: Build + run: make + + linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15.7 + - name: Build kg and kgctl for all Linux Architectures + run: make all-build + + darwin: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15.7 + - name: Build kgctl for Darwin + run: make OS=darwin + + windows: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15.7 + - name: Build kgctl for Windows + run: make OS=windows + + unit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15.7 + - name: Run Unit Tests + run: make unit + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15.7 + - name: Lint Code + run: make lint + + container: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15.7 + - name: Enable Experimental Docker CLI + run: | + echo $'{\n "experimental": true\n}' | sudo tee /etc/docker/daemon.json + mkdir -p ~/.docker + echo $'{\n "experimental": "enabled"\n}' | sudo tee ~/.docker/config.json + sudo service docker restart + docker version -f '{{.Client.Experimental}}' + docker version -f '{{.Server.Experimental}}' + docker buildx version + - name: Container + run: make container + + push: + if: github.event_name != 'pull_request' + needs: + - build + - linux + - darwin + - windows + - unit + - lint + - container + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15.7 + - name: Enable Experimental Docker CLI + run: | + echo $'{\n "experimental": true\n}' | sudo tee /etc/docker/daemon.json + mkdir -p ~/.docker + echo $'{\n "experimental": "enabled"\n}' | sudo tee ~/.docker/config.json + sudo service docker restart + docker version -f '{{.Client.Experimental}}' + docker version -f '{{.Server.Experimental}}' + docker buildx version + - name: Set up QEMU + uses: docker/setup-qemu-action@master + with: + platforms: all + - name: Login to DockerHub + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build and push + if: github.event_name != 'pull_request' + run: make manifest + - name: Build and push latest + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' + run: make manifest-latest diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 819c96e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,34 +0,0 @@ -sudo: required - -dist: xenial - -language: go - -services: - - docker - -go: - - 1.14.2 - -env: - - GO111MODULE=on DOCKER_CLI_EXPERIMENTAL=enabled - -before_install: - - sudo apt-get update && sudo apt-get -y install jq - -install: true - -script: - - make - - make all-build - - make OS=darwin - - make OS=windows - - make clean - - make unit - - make lint - - make container - -after_success: - - docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" - - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - make manifest && [ -z "$TRAVIS_TAG" ] && [ "$TRAVIS_BRANCH" == "master" ] && make manifest-latest diff --git a/Makefile b/Makefile index 0a6a446..6fed1b1 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ OPENAPI_GEN_BINARY := bin/openapi-gen GOLINT_BINARY := bin/golint EMBEDMD_BINARY := bin/embedmd -BUILD_IMAGE ?= golang:1.14.2-alpine +BUILD_IMAGE ?= golang:1.15.7-alpine BASE_IMAGE ?= alpine:3.12 build: $(BINS) @@ -197,7 +197,7 @@ header: .header FILES=; \ for f in $(GO_FILES); do \ for i in 0 1 2 3 4 5; do \ - FILE=$$(tail -n +$$i $$f | head -n $$HEADER_LEN | sed "s/[0-9]\{4\}/YEAR/"); \ + FILE=$$(t=$$(mktemp) && tail -n +$$i $$f > $$t && head -n $$HEADER_LEN $$t | sed "s/[0-9]\{4\}/YEAR/"); \ [ "$$FILE" = "$$HEADER" ] && continue 2; \ done; \ FILES="$$FILES$$f "; \ diff --git a/README.md b/README.md index c16cceb..545fc97 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Kilo is a multi-cloud network overlay built on WireGuard and designed for Kubernetes. -[![Build Status](https://travis-ci.org/squat/kilo.svg?branch=master)](https://travis-ci.org/squat/kilo) +[![Build Status](https://github.com/squat/kilo/workflows/CI/badge.svg)](https://github.com/squat/kilo/actions?query=workflow%3ACI) [![Go Report Card](https://goreportcard.com/badge/github.com/squat/kilo)](https://goreportcard.com/report/github.com/squat/kilo) ## Overview diff --git a/go.mod b/go.mod index 9518a1d..a115d6d 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/squat/kilo -go 1.14 +go 1.15 require ( github.com/PuerkitoBio/purell v1.1.1 // indirect