From 8334b732965ab486cbcd797a1268ffb61ea575a2 Mon Sep 17 00:00:00 2001 From: Tomofumi Hayashi Date: Mon, 10 Feb 2020 14:58:53 +0900 Subject: [PATCH] Add Github Actions for CI pipeline, to be replace with travis --- .../workflows/docker-build-push-master.yml | 53 ++++++++++++++++ .../workflows/docker-build-push-release.yml | 61 +++++++++++++++++++ .github/workflows/docker-build.yml | 22 +++++++ .github/workflows/go-build-ppc64.yml | 25 ++++++++ .github/workflows/go-build-test-amd64.yml | 58 ++++++++++++++++++ .github/workflows/relase-binary.yml | 30 +++++++++ 6 files changed, 249 insertions(+) create mode 100644 .github/workflows/docker-build-push-master.yml create mode 100644 .github/workflows/docker-build-push-release.yml create mode 100644 .github/workflows/docker-build.yml create mode 100644 .github/workflows/go-build-ppc64.yml create mode 100644 .github/workflows/go-build-test-amd64.yml create mode 100644 .github/workflows/relase-binary.yml diff --git a/.github/workflows/docker-build-push-master.yml b/.github/workflows/docker-build-push-master.yml new file mode 100644 index 000000000..9da4b8703 --- /dev/null +++ b/.github/workflows/docker-build-push-master.yml @@ -0,0 +1,53 @@ +name: Docker-build-push-latest +on: + push: + branches: + - master +jobs: + build: + name: Docker build + runs-on: ubuntu-latest + env: + DOCKER_CLI_EXPERIMENTAL: enabled + GO111MODULE: on + TARGET: amd64 + REPOSITORY: nfvpe/multus + REPOSITORY_USER: nfvperobot + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Build latest-amd64 + run: docker build -t ${REPOSITORY}:latest-amd64 . + + - name: Build latest-ppc64le + run: docker build -t ${REPOSITORY}:latest-ppc64le -f Dockerfile.ppc64le . + + - name: Build latest-origin + run: docker build -t ${REPOSITORY}:latest-origin -f Dockerfile.openshift . + + - name: Tag snapshot + run: | + docker tag ${REPOSITORY}:latest-amd64 ${REPOSITORY}:snapshot-amd64 + docker tag ${REPOSITORY}:latest-ppc64le ${REPOSITORY}:snapshot-ppc64le + + - name: Login to registry + run: docker login -u ${REPOSITORY_USER} -p ${{ secrets. REPOSITORY_PASS }} + + - name: Push latest/snapshot images + run: | + docker push ${REPOSITORY}:latest-amd64 + docker push ${REPOSITORY}:latest-ppc64le + docker push ${REPOSITORY}:snapshot-amd64 + docker push ${REPOSITORY}:snapshot-ppc64le + + - name: Create manifest for multi-arch images + run: | + docker manifest create ${REPOSITORY}:snapshot ${REPOSITORY}:snapshot-amd64 ${REPOSITORY}:snapshot-ppc64le + docker manifest annotate ${REPOSITORY}:snapshot ${REPOSITORY}:snapshot-amd64 --arch amd64 + docker manifest annotate ${REPOSITORY}:snapshot ${REPOSITORY}:snapshot-ppc64le --arch ppc64le + docker manifest push ${REPOSITORY}:snapshot + docker manifest create ${REPOSITORY}:latest ${REPOSITORY}:latest-amd64 ${REPOSITORY}:latest-ppc64le + docker manifest annotate ${REPOSITORY}:latest ${REPOSITORY}:latest-amd64 --arch amd64 + docker manifest annotate ${REPOSITORY}:latest ${REPOSITORY}:latest-ppc64le --arch ppc64le + docker manifest push ${REPOSITORY}:latest diff --git a/.github/workflows/docker-build-push-release.yml b/.github/workflows/docker-build-push-release.yml new file mode 100644 index 000000000..03ecd4316 --- /dev/null +++ b/.github/workflows/docker-build-push-release.yml @@ -0,0 +1,61 @@ +name: Docker-build-push-stable +on: + push: + tags: + - v* +jobs: + build: + name: Docker build + runs-on: ubuntu-latest + env: + DOCKER_CLI_EXPERIMENTAL: enabled + GO111MODULE: on + TARGET: amd64 + REPOSITORY: nfvpe/multus + REPOSITORY_USER: nfvperobot + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Build latest-amd64 + run: docker build -t ${REPOSITORY}:latest-amd64 . + + - name: Build latest-ppc64le + run: docker build -t ${REPOSITORY}:latest-ppc64le -f Dockerfile.ppc64le . + + - name: Build latest-origin + run: docker build -t ${REPOSITORY}:latest-origin -f Dockerfile.openshift . + + - name: Tag stable + run: | + docker tag ${REPOSITORY}:latest-amd64 ${REPOSITORY}:stable-amd64 + docker tag ${REPOSITORY}:latest-ppc64le ${REPOSITORY}:stable-ppc64le + docker tag ${REPOSITORY}:latest-amd64 ${REPOSITORY}:${GITHUB_REF##*/}-amd64 + docker tag ${REPOSITORY}:latest-ppc64le ${REPOSITORY}:${GITHUB_REF##*/}-ppc64le + + - name: Login to registry + run: docker login -u ${REPOSITORY_USER} -p ${{ secrets. REPOSITORY_PASS }} + + - name: Push latest/snapshot images + run: | + docker push ${REPOSITORY}:latest-amd64 + docker push ${REPOSITORY}:latest-ppc64le + docker push ${REPOSITORY}:stable-amd64 + docker push ${REPOSITORY}:stable-ppc64le + docker push ${REPOSITORY}:${GITHUB_REF##*/}-amd64 + docker push ${REPOSITORY}:${GITHUB_REF##*/}-ppc64le + + - name: Create manifest for multi-arch images + run: | + docker manifest create ${REPOSITORY}:stable ${REPOSITORY}:stable-amd64 ${REPOSITORY}:stable-ppc64le + docker manifest annotate ${REPOSITORY}:stable ${REPOSITORY}:stable-amd64 --arch amd64 + docker manifest annotate ${REPOSITORY}:stable ${REPOSITORY}:stable-ppc64le --arch ppc64le + docker manifest push ${REPOSITORY}:stable + docker manifest create ${REPOSITORY}:latest ${REPOSITORY}:latest-amd64 ${REPOSITORY}:latest-ppc64le + docker manifest annotate ${REPOSITORY}:latest ${REPOSITORY}:latest-amd64 --arch amd64 + docker manifest annotate ${REPOSITORY}:latest ${REPOSITORY}:latest-ppc64le --arch ppc64le + docker manifest push ${REPOSITORY}:latest + docker manifest create ${REPOSITORY}:${GITHUB_REF##*/} ${REPOSITORY}:${GITHUB_REF##*/}-amd64 ${REPOSITORY}:${GITHUB_REF##*/}-ppc64le + docker manifest annotate ${REPOSITORY}:${GITHUB_REF##*/} ${REPOSITORY}:${GITHUB_REF##*/}-amd64 --arch amd64 + docker manifest annotate ${REPOSITORY}:${GITHUB_REF##*/} ${REPOSITORY}:${GITHUB_REF##*/}-ppc64le --arch ppc64le + docker manifest push ${REPOSITORY}:${GITHUB_REF##*/} diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 000000000..d3ce45a37 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,22 @@ +name: Docker-build +on: [pull_request] +jobs: + build: + name: Docker build + runs-on: ubuntu-latest + env: + DOCKER_CLI_EXPERIMENTAL: enabled + GO111MODULE: on + REPOSITORY: nfvpe/multus + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Build latest-amd64 + run: docker build -t ${REPOSITORY}:latest-amd64 . + + - name: Build latest-ppc64le + run: docker build -t ${REPOSITORY}:latest-ppc64le -f Dockerfile.ppc64le . + + - name: Build latest-origin + run: docker build -t ${REPOSITORY}:latest-origin -f Dockerfile.openshift . diff --git a/.github/workflows/go-build-ppc64.yml b/.github/workflows/go-build-ppc64.yml new file mode 100644 index 000000000..f7519737c --- /dev/null +++ b/.github/workflows/go-build-ppc64.yml @@ -0,0 +1,25 @@ +name: Go-build-ppc64le +on: [push, pull_request] +jobs: + + build: + name: Build and test + runs-on: ubuntu-latest + if: > + (( github.event.pull_request.head.repo.owner.login != github.event.pull_request.base.repo.owner.login ) && + github.event_name == 'pull_request' ) || (github.event_name == 'push' && github.event.commits != '[]' ) + env: + GO111MODULE: on + TARGET: ppc64le + steps: + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Build + run: GOARCH="${TARGET}" ./build diff --git a/.github/workflows/go-build-test-amd64.yml b/.github/workflows/go-build-test-amd64.yml new file mode 100644 index 000000000..bd566780b --- /dev/null +++ b/.github/workflows/go-build-test-amd64.yml @@ -0,0 +1,58 @@ +name: Go-build-and-test-amd64 +on: [push, pull_request] +jobs: + + build: + name: Build and test + runs-on: ubuntu-latest + if: > + (( github.event.pull_request.head.repo.owner.login != github.event.pull_request.base.repo.owner.login ) && + github.event_name == 'pull_request' ) || (github.event_name == 'push' && github.event.commits != '[]' ) + env: + GO111MODULE: on + TARGET: amd64 + steps: + - name: Dump GitHub login + env: + GITHUB_LOGIN: ${{ github.event.pull_request.head.repo.owner.login }} + run: echo "$GITHUB_LOGIN" + + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: install goberalls + run: go get github.com/mattn/goveralls + + - name: install golint + run: go get -u golang.org/x/lint/golint + + - name: golint + run: golint ./... | grep -v vendor | grep -v ALL_CAPS | xargs -r false + + - name: gofmt + run: go fmt ./... + + - name: go vet + run: go vet ./... + + - name: Build + run: GOARCH="${TARGET}" ./build + + - name: Go test + run: sudo ./test.sh + + - name: goveralls + uses: shogo82148/actions-goveralls@v1 + with: + path-to-profile: coverage.out diff --git a/.github/workflows/relase-binary.yml b/.github/workflows/relase-binary.yml new file mode 100644 index 000000000..55cbc4d6b --- /dev/null +++ b/.github/workflows/relase-binary.yml @@ -0,0 +1,30 @@ +name: Release-binaries + +on: + push: + tags: + - v* + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Unshallow + run: git fetch --prune --unshallow + - + name: Set up Go + uses: actions/setup-go@v1 + with: + go-version: 1.13.x + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v1 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}