git » spf » commit 6140b40

ci: Use GitHub actions instead of GitLab CI

author Alberto Bertogli
2022-11-20 11:30:51 UTC
committer Alberto Bertogli
2022-11-20 11:41:13 UTC
parent 231cd74e89f2e06e5723a2902cd8b2212500a83a

ci: Use GitHub actions instead of GitLab CI

I'm running against the GitLab CI usage limits, and unfortunately that
causes the pipelines to error out, instead of pausing/not running them.
Those false negatives are confusing and misleading.

Move the CI to GitHub actions for now, which has much higher usage
limits.

.github/workflows/tests.yaml +50 -0
.gitignore +1 -0
.gitlab-ci.yml +0 -25
README.md +1 -1

diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml
new file mode 100644
index 0000000..f663c3a
--- /dev/null
+++ b/.github/workflows/tests.yaml
@@ -0,0 +1,50 @@
+name: "tests"
+
+on:
+  push:
+    branches: [ "master", "next" ]
+  pull_request:
+    # The branches below must be a subset of the branches above
+    branches: [ "master", "next" ]
+  schedule:
+    - cron: '16 21 * * 6'
+
+jobs:
+  tests:
+    runs-on: ubuntu-latest
+    timeout-minutes: 5
+    strategy:
+      matrix:
+        # Oldest supported version, and latest.
+        go-version: [ '1.15.x', '1.x' ]
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions/setup-go@v3
+        with:
+          go-version: ${{ matrix.go-version }}
+          check-latest: true
+          cache: true
+
+      - run: go test ./...
+      - run: go test -race ./...
+
+  coverage:
+    needs: tests
+    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
+          cache: true
+
+      - name: test -cover
+        run: go test -covermode=count -coverprofile=coverage.out
+
+      - name: install goveralls
+        run: go install github.com/mattn/goveralls@latest
+
+      - name: upload coverage
+        run: goveralls -coverprofile=coverage.out -repotoken=${{ secrets.COVERALLS_TOKEN }}
diff --git a/.gitignore b/.gitignore
index 7cf7ba3..4496a23 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@
 # Exceptions to the rule above: files we care about that would otherwise be
 # excluded.
 !.gitignore
+!.github
 
 # go-fuzz build artifacts.
 *-fuzz.zip
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
deleted file mode 100644
index dbcdeb0..0000000
--- a/.gitlab-ci.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-# Configuration for the GitLab CI.
-
-# Go tests, on various Go versions.
-.golang_template: &golang
-  stage: test
-  script:
-    - go test ./...
-    - go test -race ./...
-
-golang_1.15:
-  <<: *golang
-  image: golang:1.15  # Oldest supported version (for now).
-
-golang_latest:
-  <<: *golang
-  image: golang:latest
-
-coverage:
-  <<: *golang
-  image: golang:latest
-  script:
-    - go test -covermode=count -coverprofile=coverage.out
-    - go install github.com/mattn/goveralls@latest
-    - goveralls -coverprofile=coverage.out -service=gitlab -repotoken=$COVERALLS_TOKEN
-
diff --git a/README.md b/README.md
index 19a14b7..28d937a 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
 # blitiri.com.ar/go/spf
 
 [![GoDoc](https://godoc.org/blitiri.com.ar/go/spf?status.svg)](https://pkg.go.dev/blitiri.com.ar/go/spf)
-[![Build Status](https://gitlab.com/albertito/spf/badges/master/pipeline.svg)](https://gitlab.com/albertito/spf/-/pipelines)
+[![Tests Status](https://img.shields.io/github/checks-status/albertito/spf/master)](https://github.com/albertito/spf/actions)
 [![Go Report Card](https://goreportcard.com/badge/github.com/albertito/spf)](https://goreportcard.com/report/github.com/albertito/spf)
 [![Coverage Status](https://coveralls.io/repos/github/albertito/spf/badge.svg?branch=next)](https://coveralls.io/github/albertito/spf)