mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-16 14:27:01 +00:00
ci: Use Github Actions to run integration tests and push Docker images
We're running against the usage limits in Gitlab CI (500), and Github Actions should have more (2000). So this patch replaces Gitlab CI with Github actions for running integration tests, and build and push Docker images (to Dockerhub and Gitlab registry). We'll see how the usage levels are in a few months.
This commit is contained in:
74
.github/workflows/docker.yml
vendored
Normal file
74
.github/workflows/docker.yml
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
name: "docker"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master", "next" ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ "master", "next" ]
|
||||
schedule:
|
||||
- cron: '29 21 * * 6'
|
||||
|
||||
env:
|
||||
HAS_DOCKER: ${{ secrets.DOCKER_REGISTRY_USER != '' }}
|
||||
HAS_GITLAB: ${{ secrets.GITLAB_REGISTRY_USER != '' }}
|
||||
|
||||
jobs:
|
||||
integration:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Docker info (for debugging)
|
||||
run: docker info
|
||||
- name: Build test image
|
||||
run: docker build -t chasquid-test -f test/Dockerfile .
|
||||
- name: Run tests
|
||||
run: docker run --name test1 chasquid-test make test
|
||||
|
||||
public-image:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
needs: integration
|
||||
if: github.event_name == 'push'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Build
|
||||
run: docker build -t chasquid -f docker/Dockerfile .
|
||||
|
||||
# Push it to Dockerhub.
|
||||
- name: Dockerhub login
|
||||
if: env.HAS_DOCKER
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_REGISTRY_USER }}
|
||||
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
|
||||
- name: Dockerhub push
|
||||
if: env.HAS_DOCKER
|
||||
run: |
|
||||
docker tag chasquid index.docker.io/${{ secrets.DOCKER_REGISTRY_USER }}/chasquid:$GITHUB_REF_NAME
|
||||
docker push index.docker.io/${{ secrets.DOCKER_REGISTRY_USER }}/chasquid:$GITHUB_REF_NAME
|
||||
- name: Dockerhub tag latest
|
||||
if: env.HAS_DOCKER && env.GITHUB_REF_NAME == 'master'
|
||||
run: |
|
||||
docker tag chasquid index.docker.io/${{ secrets.DOCKER_REGISTRY_USER }}/chasquid:latest
|
||||
docker push index.docker.io/${{ secrets.DOCKER_REGISTRY_USER }}/chasquid:latest
|
||||
|
||||
# Push it to Gitlab.
|
||||
- name: Gitlab login
|
||||
if: env.HAS_GITLAB
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: registry.gitlab.com
|
||||
username: ${{ secrets.GITLAB_REGISTRY_USER }}
|
||||
password: ${{ secrets.GITLAB_REGISTRY_TOKEN }}
|
||||
- name: Gitlab push
|
||||
if: env.HAS_GITLAB
|
||||
run: |
|
||||
docker tag chasquid registry.gitlab.com/albertito/chasquid:$GITHUB_REF_NAME
|
||||
docker push registry.gitlab.com/albertito/chasquid:$GITHUB_REF_NAME
|
||||
- name: Gitlab tag latest
|
||||
if: env.HAS_GITLAB && env.GITHUB_REF_NAME == 'master'
|
||||
run: |
|
||||
docker tag chasquid registry.gitlab.com/albertito/chasquid:latest
|
||||
docker push registry.gitlab.com/albertito/chasquid:latest
|
||||
39
.github/workflows/gotests.yml
vendored
Normal file
39
.github/workflows/gotests.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
name: "gotests"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master", "next" ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ "master", "next" ]
|
||||
schedule:
|
||||
- cron: '29 21 * * 6'
|
||||
|
||||
jobs:
|
||||
oldest_supported:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
- name: normal tests
|
||||
run: go test ./...
|
||||
- name: race tests
|
||||
run: go test -race ./...
|
||||
|
||||
latest:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: "1.x"
|
||||
check-latest: true
|
||||
- name: normal tests
|
||||
run: go test ./...
|
||||
- name: race tests
|
||||
run: go test -race ./...
|
||||
|
||||
102
.gitlab-ci.yml
102
.gitlab-ci.yml
@@ -1,102 +0,0 @@
|
||||
|
||||
stages:
|
||||
- test
|
||||
- image
|
||||
|
||||
# Go tests, on various Go versions.
|
||||
.golang_template: &golang
|
||||
stage: test
|
||||
before_script:
|
||||
- useradd --create-home --user-group testing
|
||||
- chown -R testing:testing $GOPATH/ .
|
||||
script:
|
||||
- su testing -c "go mod download"
|
||||
- su testing -c "go get ./..."
|
||||
- su testing -c "make all"
|
||||
- su testing -c "go test ./..."
|
||||
- su testing -c "go test -race ./..."
|
||||
|
||||
golang_1.17:
|
||||
<<: *golang
|
||||
image: golang:1.17 # Oldest supported Go version.
|
||||
|
||||
golang_latest:
|
||||
<<: *golang
|
||||
image: golang:latest
|
||||
|
||||
# Integration test, using the module versions from the repository.
|
||||
integration_stable:
|
||||
stage: test
|
||||
image: docker:stable
|
||||
services:
|
||||
- docker:dind
|
||||
script:
|
||||
- docker info
|
||||
- docker build -t chasquid-test -f test/Dockerfile .
|
||||
- docker run chasquid-test env
|
||||
- docker run --name test1 chasquid-test make test
|
||||
after_script:
|
||||
- docker cp test1:/go/src/blitiri.com.ar/go/chasquid docker-out/
|
||||
artifacts:
|
||||
when: always
|
||||
expire_in: 1 hour
|
||||
paths:
|
||||
- docker-out/
|
||||
|
||||
|
||||
# Integration test, using the latest module versions.
|
||||
integration_latest:
|
||||
stage: test
|
||||
image: docker:stable
|
||||
services:
|
||||
- docker:dind
|
||||
script:
|
||||
- docker info
|
||||
- docker build -t chasquid-test --build-arg GO_GET_ARGS="-u=patch" -f test/Dockerfile .
|
||||
- docker run chasquid-test env
|
||||
- docker run --name test1 chasquid-test make test
|
||||
after_script:
|
||||
- docker cp test1:/go/src/blitiri.com.ar/go/chasquid docker-out/
|
||||
artifacts:
|
||||
when: always
|
||||
expire_in: 1 hour
|
||||
paths:
|
||||
- docker-out/
|
||||
|
||||
# Build docker image, upload to gitlab registry.
|
||||
gitlab:
|
||||
stage: image
|
||||
rules:
|
||||
- if: '$CI_REGISTRY_IMAGE'
|
||||
image: docker:stable
|
||||
services:
|
||||
- docker:dind
|
||||
script:
|
||||
- docker info
|
||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME -f docker/Dockerfile .
|
||||
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
|
||||
- |
|
||||
if [ $CI_COMMIT_REF_NAME == master ]; then
|
||||
docker tag $CI_REGISTRY_IMAGE:master $CI_REGISTRY_IMAGE:latest
|
||||
docker push $CI_REGISTRY_IMAGE:latest
|
||||
fi
|
||||
|
||||
# Build docker image, upload to dockerhub registry.
|
||||
dockerhub:
|
||||
stage: image
|
||||
rules:
|
||||
- if: '$DOCKER_REGISTRY_USER'
|
||||
image: docker:stable
|
||||
services:
|
||||
- docker:dind
|
||||
script:
|
||||
- docker info
|
||||
- docker login -u $DOCKER_REGISTRY_USER -p $DOCKER_REGISTRY_PASSWORD docker.io
|
||||
- docker build -t index.docker.io/albertito/chasquid:$CI_COMMIT_REF_NAME -f docker/Dockerfile .
|
||||
- docker push index.docker.io/albertito/chasquid:$CI_COMMIT_REF_NAME
|
||||
- |
|
||||
if [ $CI_COMMIT_REF_NAME == master ]; then
|
||||
docker tag index.docker.io/albertito/chasquid:master index.docker.io/albertito/chasquid:latest
|
||||
docker push index.docker.io/albertito/chasquid:latest
|
||||
fi
|
||||
@@ -9,8 +9,7 @@ It is designed mainly for individuals and small groups.
|
||||
It's written in [Go](https://golang.org), and distributed under the
|
||||
[Apache license 2.0](http://en.wikipedia.org/wiki/Apache_License).
|
||||
|
||||
[](https://gitlab.com/albertito/chasquid/pipelines)
|
||||
[](https://cirrus-ci.com/github/albertito/chasquid)
|
||||
[](https://github.com/albertito/chasquid/actions)
|
||||
[](https://goreportcard.com/report/github.com/albertito/chasquid)
|
||||
[](https://blitiri.com.ar/p/chasquid/coverage.html)
|
||||
[](https://blitiri.com.ar/p/chasquid/)
|
||||
|
||||
@@ -93,16 +93,13 @@ constrained or non supported environments.
|
||||
There are two sets of automated tests which are run on every commit to
|
||||
upstream, and weekly:
|
||||
|
||||
* [GitLab CI](https://gitlab.com/albertito/chasquid/commits/master),
|
||||
configured in the `.gitlab-ci.yml` file, runs the Go tests and the
|
||||
integration tests (using [docker](#docker)).
|
||||
The integration tests are run twice: once against the dependencies listed in
|
||||
`go.mod`, and once against the latest version of the dependencies.
|
||||
It also builds the [public Docker images](docker.md).
|
||||
* [Github Actions](https://github.com/albertito/chasquid/actions),
|
||||
configured in the `.github` directory, runs the Go tests, the integration
|
||||
tests, checks for vulnerabilities, and finally
|
||||
also builds the [public Docker images](docker.md).
|
||||
|
||||
* [Cirrus CI](https://gitlab.com/albertito/chasquid/pipelines),
|
||||
configured in the `.cirrus.yml` file, runs Go tests on FreeBSD, and a
|
||||
comprehensive linter.
|
||||
* [Cirrus CI](https://cirrus-ci.com/github/albertito/chasquid),
|
||||
configured in the `.cirrus.yml` file, runs Go tests on FreeBSD.
|
||||
|
||||
|
||||
## Coverage
|
||||
|
||||
Reference in New Issue
Block a user