move to github actions from drone (#1823)

* add github actions workflow for tag releases

* migrate drone build &test step to github actions

* fix minio service

* fix indentation

* fix dependency syntax

* remove needs keyword

* fix service hostnames, add protectedredis

* update protected redis docker image

* fix too many args error

* exclude vendor dir from gofmt

* fix fmt errors

* fix fmt errors

* rm .drone.yml

* rename workflow name

* break test step

* remove vendor step

* use makefile rule

* use buildx
This commit is contained in:
Ashish Ranjan
2023-02-23 12:17:37 +05:30
committed by GitHub
parent dbe3b5d145
commit 3f26845cff
15 changed files with 139 additions and 222 deletions
-203
View File
@@ -1,203 +0,0 @@
---
kind: pipeline
name: default
steps:
- name: download-dependencies
image: golang:1.19
commands:
# wait for services to be ready.
# - cd scripts/liveness_probe
# - go run .
# - cd ../..
- go mod download
- go mod vendor # this is for when the Dockerfile gets built
environment:
GO111MODULE: on
# temporarily disabled until we move to Actions
# GOPROXY: http://athens-proxy:3000
volumes:
- name: cache
path: /go
- name: build
image: golang:1.19
commands:
# build
- go build cmd/proxy/*.go
# test
- ./scripts/check_gofmt.sh
- go vet ./...
- go test -v ./...
# end to end test
- ./main & # run the just-built athens server
- sleep 3 # wait for it to spin up
- curl localhost:3000
- mkdir -p ~/happy
- mkdir -p ~/emptygopath # ensure the gopath has no modules cached.
- cd ~/happy
- git clone https://github.com/athens-artifacts/happy-path.git
- cd happy-path
- GOPATH=~/emptygopath GOPROXY=http://localhost:3000 go build
environment:
GO111MODULE: on
ATHENS_MONGO_STORAGE_URL: mongodb://mongo:27017
ATHENS_MINIO_ENDPOINT: minio:9000
REDIS_TEST_ENDPOINT: redis:6379
REDIS_SENTINEL_TEST_ENDPOINT: redis-sentinel:26379
REDIS_SENTINEL_TEST_MASTER_NAME: redis-1
REDIS_SENTINEL_TEST_PASSWORD: sekret
PROTECTED_REDIS_TEST_ENDPOINT: protectedredis:6380
ATHENS_PROTECTED_REDIS_PASSWORD: AthensPass1
GCS_SERVICE_ACCOUNT:
from_secret: GCS_SERVICE_ACCOUNT
GCS_PROJECT_ID:
from_secret: GOOGLE_CLOUD_PROJECT
ATHENS_AZURE_ACCOUNT_NAME:
from_secret: ATHENS_AZURE_ACCOUNT_NAME
ATHENS_AZURE_ACCOUNT_KEY:
from_secret: ATHENS_AZURE_ACCOUNT_KEY
when:
branch:
- main
event:
- push
- pull_request
volumes:
- name: cache
path: /go
depends_on:
- redis
- redis-sentinel
- name: docker-latest
image: plugins/docker
settings:
username:
from_secret: DOCKER_USER
password:
from_secret: DOCKER_PASSWORD
repo: gomods/athens
tags:
- canary
dockerfile: cmd/proxy/Dockerfile
build_args:
- VERSION=${DRONE_COMMIT}
when:
branch:
- main
event:
- push
- name: docker-latest-commit-sha
image: plugins/docker
settings:
username:
from_secret: DOCKER_USER
password:
from_secret: DOCKER_PASSWORD
repo: gomods/athens-dev
tags:
- ${DRONE_COMMIT:0:7}
dockerfile: cmd/proxy/Dockerfile
build_args:
- VERSION=${DRONE_COMMIT}
when:
branch:
- main
event:
- push
- name: docker-release
image: plugins/docker
settings:
username:
from_secret: DOCKER_USER
password:
from_secret: DOCKER_PASSWORD
repo: gomods/athens
tags:
- ${DRONE_TAG}
- latest
dockerfile: cmd/proxy/Dockerfile
build_args:
- VERSION=${DRONE_TAG}
when:
event:
- tag
- name: publish-helm
image: gomods/drone-helm
settings:
charts_repo: https://athens.blob.core.windows.net
environment:
AZURE_STORAGE_CONNECTION_STRING:
from_secret: AZURE_STORAGE_CONNECTION_STRING
when:
branch:
- main
event:
- push
# Here we can add any backend storage that can be tested.
services:
- name: mongo
image: mongo
ports:
- 27017
- name: minio
image: minio/minio:latest
command:
- server
- /data
ports:
- 9000
environment:
MINIO_ACCESS_KEY: minio
MINIO_SECRET_KEY: minio123
- name: redis
image: redis
ports:
- 6379
- name: redis-sentinel
image: bitnami/redis-sentinel
environment:
REDIS_MASTER_HOST: redis
REDIS_MASTER_SET: redis-1
REDIS_SENTINEL_PASSWORD: sekret
REDIS_SENTINEL_QUORUM: "1"
ports:
- 26379
depends_on:
- redis
- name: protectedredis
image: redis
ports:
- 6380
commands:
- "redis-server ./test/redis.conf"
- name: athens-proxy
image: gomods/athens:canary
pull: always
ports:
- 3000
environment:
ATHENS_GOGET_WORKERS: 5
ATHENS_PROTOCOL_WORKERS: 10
ATHENS_SINGLE_FLIGHT_TYPE: gcp
ATHENS_STORAGE_TYPE: gcp
ATHENS_STORAGE_GCP_BUCKET: "athens_ci_build"
ATHENS_STORAGE_GCP_JSON_KEY:
from_secret: GCS_SERVICE_ACCOUNT
volumes:
- name: cache
temp: {}
---
kind: signature
hmac: 8ee2a04fedfd1a0c1ab3da19a3441485bf447de3e04fe057f626c83454a042b6
...
+62
View File
@@ -0,0 +1,62 @@
name: continuous-integration
on:
- push
- pull_request
jobs:
build:
env:
ATHENS_MONGO_STORAGE_URL: mongodb://localhost:27017
ATHENS_MINIO_ENDPOINT: localhost:9000
REDIS_TEST_ENDPOINT: localhost:6379
REDIS_SENTINEL_TEST_ENDPOINT: localhost:26379
REDIS_SENTINEL_TEST_MASTER_NAME: redis-1
REDIS_SENTINEL_TEST_PASSWORD: sekret
PROTECTED_REDIS_TEST_ENDPOINT: localhost:6380
ATHENS_PROTECTED_REDIS_PASSWORD: AthensPass1
runs-on: ubuntu-latest
services:
mongo:
image: mongo
ports:
- 27017:27017
minio:
image: minio/minio:edge-cicd
ports:
- 9000:9000
env:
MINIO_ACCESS_KEY: minio
MINIO_SECRET_KEY: minio123
redis:
image: redis
ports:
- 6379:6379
redis-sentinel:
image: bitnami/redis-sentinel
env:
REDIS_MASTER_HOST: redis
REDIS_MASTER_SET: redis-1
REDIS_SENTINEL_PASSWORD: sekret
REDIS_SENTINEL_QUORUM: "1"
ports:
- 26379:26379
protectedredis:
image: bitnami/redis
ports:
- 6380:6380
env:
REDIS_PORT_NUMBER: 6380
REDIS_PASSWORD: AthensPass1
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
cache: true
- name: Run linter
run: make verify
- name: Unit tests
run: go test -v -race ./...
- name: End to end tests
if: success() || failure()
run: make test-e2e
+29
View File
@@ -0,0 +1,29 @@
name: Release canary and commit tags
on:
push:
branches:
- main
jobs:
docker-push-main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push canary tag
uses: docker/build-push-action@v4
with:
file: cmd/proxy/Dockerfile
build-args: VERSION=${{github.sha}}
tags: gomods/athens:canary
- name: Build and push commit tag
uses: docker/build-push-action@v4
with:
file: cmd/proxy/Dockerfile
build-args: VERSION=${{github.sha}}
tags: gomods/athens-dev:${GITHUB_SHA::7}
+23
View File
@@ -0,0 +1,23 @@
name: release-latest
on:
push:
tags:
- '**'
jobs:
docker-push-main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push latest tag
uses: docker/build-push-action@v4
with:
file: cmd/proxy/Dockerfile
build-args: VERSION=${{github.sha}}
tags: gomods/athens:latest
-1
View File
@@ -12,7 +12,6 @@ builds:
- darwin
goarch:
- amd64
- x86_64
main: cmd/proxy/main.go
binary: athens
ldflags:
+1
View File
@@ -1,3 +1,4 @@
//go:build e2etests
// +build e2etests
package e2etests
+1
View File
@@ -1,3 +1,4 @@
//go:build e2etests
// +build e2etests
package e2etests
+1
View File
@@ -22,6 +22,7 @@ var version, buildDate string
//
// i.e.
// Build Details:
//
// Version: v0.1.0-155-g1a20f8b
// Date: 2018-11-05-14:33:14-UTC
func String() string {
+4 -1
View File
@@ -25,11 +25,14 @@ type Filter struct {
// Configuration consists of two operations: + for include and - for exclude
// e.g.
// - github.com/a
// + github.com/a/b
// - github.com/a/b
//
// will communicate all modules except github.com/a and its children, but github.com/a/b will be communicated
// example 2:
//
// -
// + github.com/a
//
// will exclude all items from communication except github.com/a
func NewFilter(filterFilePath string) (*Filter, error) {
// Do not return an error if the file path is empty
+1 -1
View File
@@ -4,10 +4,10 @@ import (
"context"
"fmt"
"contrib.go.opencensus.io/exporter/jaeger"
"contrib.go.opencensus.io/exporter/stackdriver"
datadog "github.com/DataDog/opencensus-go-exporter-datadog"
"github.com/gomods/athens/pkg/errors"
"contrib.go.opencensus.io/exporter/jaeger"
"go.opencensus.io/trace"
)
+1 -2
View File
@@ -2,7 +2,7 @@
Package gcp provides a storage driver to upload module files to a google
cloud platform storage bucket.
Configuration
# Configuration
Environment variables:
@@ -15,6 +15,5 @@ Example:
export ATHENS_STORAGE_GCP_BUCKET="fancy-pony-33928.appspot.com"
Fish:
set -x ATHENS_STORAGE_GCP_BUCKET fancy-pony-339288.appspot.com
*/
package gcp
+2 -2
View File
@@ -2,9 +2,10 @@
Package s3 provides a storage driver to upload module files to
amazon s3 storage bucket.
Configuration
# Configuration
Environment variables:
AWS_REGION // region for this storage, e.g 'us-west-2'
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
@@ -20,6 +21,5 @@ Example:
export AWS_REGION="us-west-2"
Fish:
set -x AWS_REGION us-west-2
*/
package s3
+4 -2
View File
@@ -4,5 +4,7 @@
# Fail if a .go file hasn't been formatted with gofmt
set -euo pipefail
GO_FILES=$(find . -iname '*.go' -type f) # All the .go files
test -z $(gofmt -s -d "$GO_FILES" | tee /dev/stderr)
GO_FILES=$(find . -iname '*.go' -type f -not -path "./vendor/*") # All the .go files
for f in $GO_FILES; do
test -z "$(gofmt -s -w "$f" | tee /dev/stderr)"
done