mirror of
https://github.com/gomods/athens
synced 2026-02-03 08:40:31 +00:00
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:
-203
@@ -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
|
||||
|
||||
...
|
||||
@@ -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
|
||||
@@ -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}
|
||||
@@ -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
|
||||
@@ -12,7 +12,6 @@ builds:
|
||||
- darwin
|
||||
goarch:
|
||||
- amd64
|
||||
- x86_64
|
||||
main: cmd/proxy/main.go
|
||||
binary: athens
|
||||
ldflags:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//go:build e2etests
|
||||
// +build e2etests
|
||||
|
||||
package e2etests
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//go:build e2etests
|
||||
// +build e2etests
|
||||
|
||||
package e2etests
|
||||
|
||||
+3
-2
@@ -22,8 +22,9 @@ var version, buildDate string
|
||||
//
|
||||
// i.e.
|
||||
// Build Details:
|
||||
// Version: v0.1.0-155-g1a20f8b
|
||||
// Date: 2018-11-05-14:33:14-UTC
|
||||
//
|
||||
// Version: v0.1.0-155-g1a20f8b
|
||||
// Date: 2018-11-05-14:33:14-UTC
|
||||
func String() string {
|
||||
return fmt.Sprintf("Build Details:\n\tVersion:\t%s\n\tDate:\t\t%s", version, buildDate)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
|
||||
//OpTests composes a testsuite to run all the Ops related tests in one group
|
||||
// OpTests composes a testsuite to run all the Ops related tests in one group
|
||||
type OpTests struct {
|
||||
suite.Suite
|
||||
}
|
||||
|
||||
@@ -24,12 +24,15 @@ type Filter struct {
|
||||
// WARNING: this is not concurrently safe
|
||||
// Configuration consists of two operations: + for include and - for exclude
|
||||
// e.g.
|
||||
// - github.com/a
|
||||
// + github.com/a/b
|
||||
// - github.com/a
|
||||
// - 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
|
||||
//
|
||||
// -
|
||||
// + 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
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
|
||||
@@ -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,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
|
||||
|
||||
@@ -80,10 +80,10 @@ func getStorage(t testing.TB) *Storage {
|
||||
}
|
||||
backend, err := New(
|
||||
&config.S3Config{
|
||||
Key: "minio",
|
||||
Secret: "minio123",
|
||||
Bucket: "gomodsaws",
|
||||
Region: "us-west-1",
|
||||
Key: "minio",
|
||||
Secret: "minio123",
|
||||
Bucket: "gomodsaws",
|
||||
Region: "us-west-1",
|
||||
ForcePathStyle: true,
|
||||
},
|
||||
config.GetTimeoutDuration(300),
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user