Skip to content

Commit

Permalink
ci: Use Github Actions to run integration tests and push Docker images
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
albertito committed Nov 13, 2022
1 parent 948cee1 commit 795f2a7
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 114 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 39 additions & 0 deletions .github/workflows/gotests.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 0 additions & 102 deletions .gitlab-ci.yml

This file was deleted.

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

[![Gitlab CI status](https://gitlab.com/albertito/chasquid/badges/master/pipeline.svg)](https://gitlab.com/albertito/chasquid/pipelines)
[![Cirrus-CI Status](https://api.cirrus-ci.com/github/albertito/chasquid.svg?branch=next)](https://cirrus-ci.com/github/albertito/chasquid)
[![Github status](https://img.shields.io/github/checks-status/albertito/chasquid/master)](https://github.com/albertito/chasquid/actions)
[![Go Report Card](https://goreportcard.com/badge/github.com/albertito/chasquid)](https://goreportcard.com/report/github.com/albertito/chasquid)
[![Coverage](https://img.shields.io/badge/coverage-next-brightgreen.svg)](https://blitiri.com.ar/p/chasquid/coverage.html)
[![Docs](https://img.shields.io/badge/docs-reference-blue.svg)](https://blitiri.com.ar/p/chasquid/)
Expand Down
17 changes: 7 additions & 10 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

* [Cirrus CI](https://gitlab.com/albertito/chasquid/pipelines),
configured in the `.cirrus.yml` file, runs Go tests on FreeBSD, and a
comprehensive linter.
* [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://cirrus-ci.com/github/albertito/chasquid),
configured in the `.cirrus.yml` file, runs Go tests on FreeBSD.


## Coverage
Expand Down

0 comments on commit 795f2a7

Please sign in to comment.