forked from TrueCloudLab/lego
chore: use GitHub Action. (#1319)
This commit is contained in:
parent
136f159d53
commit
d9248c9d4f
9 changed files with 190 additions and 126 deletions
45
.github/workflows/go-cross.yml
vendored
Normal file
45
.github/workflows/go-cross.yml
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
name: Go Matrix
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
|
||||
cross:
|
||||
name: Go
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [ 1.14, 1.15, 1.x ]
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
|
||||
steps:
|
||||
# https://github.com/marketplace/actions/setup-go-environment
|
||||
- name: Set up Go ${{ matrix.go-version }}
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
|
||||
# https://github.com/marketplace/actions/checkout
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# https://github.com/marketplace/actions/cache
|
||||
- name: Cache Go modules
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/go/pkg/mod # Module download cache
|
||||
~/.cache/go-build # Build cache (Linux)
|
||||
~/Library/Caches/go-build # Build cache (Mac)
|
||||
'%LocalAppData%\go-build' # Build cache (Windows)
|
||||
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-${{ matrix.go-version }}-go-
|
||||
|
||||
- name: Test
|
||||
run: go test -v -cover ./...
|
||||
|
||||
- name: Build
|
||||
run: go build -v -ldflags "-s -w" -trimpath -o ./dist/lego ./cmd/lego/
|
127
.github/workflows/main.yml
vendored
Normal file
127
.github/workflows/main.yml
vendored
Normal file
|
@ -0,0 +1,127 @@
|
|||
name: Main
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- v*
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
|
||||
main:
|
||||
name: Main Process
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GO_VERSION: 1.15
|
||||
GOLANGCI_LINT_VERSION: v1.33.0
|
||||
HUGO_VERSION: 0.54.0
|
||||
SEIHON_VERSION: v0.5.1
|
||||
CGO_ENABLED: 0
|
||||
LEGO_E2E_TESTS: CI
|
||||
MEMCACHED_HOSTS: localhost:11211
|
||||
|
||||
steps:
|
||||
|
||||
# https://github.com/marketplace/actions/setup-go-environment
|
||||
- name: Set up Go ${{ env.GO_VERSION }}
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
# https://github.com/marketplace/actions/checkout
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# https://github.com/marketplace/actions/cache
|
||||
- name: Cache Go modules
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
|
||||
- name: Check and get dependencies
|
||||
run: |
|
||||
go mod tidy
|
||||
git diff --exit-code go.mod
|
||||
git diff --exit-code go.sum
|
||||
go mod download
|
||||
|
||||
- name: Documentation validation
|
||||
run: make validate-doc
|
||||
|
||||
# https://golangci-lint.run/usage/install#other-ci
|
||||
- name: Install golangci-lint ${{ env.GOLANGCI_LINT_VERSION }}
|
||||
run: |
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION}
|
||||
golangci-lint --version
|
||||
|
||||
- name: Install Pebble and challtestsrv
|
||||
run: GO111MODULE=off go get -u github.com/letsencrypt/pebble/...
|
||||
|
||||
- name: Set up a Memcached server
|
||||
uses: niden/actions-memcached@v7
|
||||
|
||||
- name: Setup /etc/hosts
|
||||
run: |
|
||||
echo "127.0.0.1 acme.wtf" | sudo tee -a /etc/hosts
|
||||
echo "127.0.0.1 lego.wtf" | sudo tee -a /etc/hosts
|
||||
echo "127.0.0.1 acme.lego.wtf" | sudo tee -a /etc/hosts
|
||||
echo "127.0.0.1 légô.wtf" | sudo tee -a /etc/hosts
|
||||
echo "127.0.0.1 xn--lg-bja9b.wtf" | sudo tee -a /etc/hosts
|
||||
|
||||
- name: Make
|
||||
run: |
|
||||
make
|
||||
make clean
|
||||
|
||||
- name: Install Hugo
|
||||
run: |
|
||||
wget -O /tmp/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_Linux-64bit.deb
|
||||
sudo dpkg -i /tmp/hugo.deb
|
||||
|
||||
- name: Build Documentation
|
||||
run: make docs-build
|
||||
|
||||
# https://github.com/marketplace/actions/github-pages
|
||||
- name: Deploy to GitHub Pages
|
||||
uses: crazy-max/ghaction-github-pages@v2
|
||||
if: github.event_name == 'push'
|
||||
with:
|
||||
target_branch: gh-pages
|
||||
build_dir: docs/public
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# https://goreleaser.com/ci/actions/
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v2
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
with:
|
||||
version: latest
|
||||
args: release --rm-dist
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_REPO }}
|
||||
|
||||
# Install Docker image multi-arch builder
|
||||
- name: Install Seihon ${{ env.SEIHON_VERSION }}
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
run: |
|
||||
curl -sSfL https://raw.githubusercontent.com/ldez/seihon/master/godownloader.sh | sh -s -- -b $(go env GOPATH)/bin ${SEIHON_VERSION}
|
||||
seihon --version
|
||||
|
||||
- name: Docker Login
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
env:
|
||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
run: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
|
||||
|
||||
- name: Publish Docker Images (Seihon)
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
run: make publish-images
|
105
.travis.yml
105
.travis.yml
|
@ -1,105 +0,0 @@
|
|||
language: go
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $GOPATH/pkg/mod
|
||||
|
||||
jobs:
|
||||
fast_finish: true
|
||||
include:
|
||||
- go: 1.14.x
|
||||
- go: 1.15.x
|
||||
env: STABLE=true
|
||||
- go: 1.x
|
||||
- go: tip
|
||||
allow_failures:
|
||||
- go: tip
|
||||
|
||||
go_import_path: github.com/go-acme/lego
|
||||
|
||||
env:
|
||||
global:
|
||||
- MEMCACHED_HOSTS=localhost:11211
|
||||
- GO111MODULE=on
|
||||
|
||||
services:
|
||||
- memcached
|
||||
|
||||
addons:
|
||||
hosts:
|
||||
# for e2e tests
|
||||
- acme.wtf
|
||||
- lego.wtf
|
||||
- acme.lego.wtf
|
||||
- légô.wtf
|
||||
- xn--lg-bja9b.wtf
|
||||
|
||||
before_install:
|
||||
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && openssl aes-256-cbc -K $encrypted_26c593b079d9_key -iv $encrypted_26c593b079d9_iv -in .gitcookies.enc -out .gitcookies -d || true'
|
||||
|
||||
# Install Pebble and challtestsrv
|
||||
- GO111MODULE=off go get -u github.com/letsencrypt/pebble/...
|
||||
|
||||
# Install linters and misspell
|
||||
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin ${GOLANGCI_LINT_VERSION}
|
||||
- golangci-lint --version
|
||||
|
||||
# Hugo - documentation
|
||||
- wget -O /tmp/hugo.deb https://github.com/gohugoio/hugo/releases/download/v0.54.0/hugo_0.54.0_Linux-64bit.deb
|
||||
- sudo dpkg -i /tmp/hugo.deb
|
||||
|
||||
# Install Docker image multi-arch builder
|
||||
- curl -sfL https://raw.githubusercontent.com/ldez/seihon/master/godownloader.sh | bash -s -- -b "${GOPATH}/bin" ${SEIHON_VERSION}
|
||||
- seihon --version
|
||||
|
||||
install:
|
||||
- go mod tidy
|
||||
- git diff --exit-code go.mod
|
||||
- git diff --exit-code go.sum
|
||||
- go mod download
|
||||
|
||||
before_script:
|
||||
- make validate-doc
|
||||
|
||||
after_success:
|
||||
- make clean
|
||||
|
||||
before_deploy:
|
||||
- >
|
||||
if ! [ "$BEFORE_DEPLOY_RUN" ]; then
|
||||
export BEFORE_DEPLOY_RUN=1;
|
||||
make docs-build;
|
||||
echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin;
|
||||
fi
|
||||
|
||||
deploy:
|
||||
- provider: pages
|
||||
local_dir: docs/public
|
||||
skip_cleanup: true
|
||||
github_token: ${GITHUB_TOKEN}
|
||||
on:
|
||||
condition: $STABLE = true
|
||||
|
||||
- provider: script
|
||||
skip_cleanup: true
|
||||
script: curl -sL https://git.io/goreleaser | bash
|
||||
on:
|
||||
tags: true
|
||||
condition: $STABLE = true
|
||||
|
||||
- provider: releases
|
||||
api_key: ${GITHUB_TOKEN}
|
||||
file: dist/lego_*
|
||||
skip_cleanup: true
|
||||
overwrite: true
|
||||
file_glob: true
|
||||
on:
|
||||
tags: true
|
||||
condition: $STABLE = true
|
||||
|
||||
- provider: script
|
||||
skip_cleanup: true
|
||||
script: make publish-images
|
||||
on:
|
||||
tags: true
|
||||
condition: $STABLE = true
|
5
Makefile
5
Makefile
|
@ -3,8 +3,6 @@
|
|||
export GO111MODULE=on
|
||||
export CGO_ENABLED=0
|
||||
|
||||
SRCS = $(shell git ls-files '*.go' | grep -v '^vendor/')
|
||||
|
||||
LEGO_IMAGE := goacme/lego
|
||||
MAIN_DIRECTORY := ./cmd/lego/
|
||||
|
||||
|
@ -40,9 +38,6 @@ e2e: clean
|
|||
checks:
|
||||
golangci-lint run
|
||||
|
||||
fmt:
|
||||
gofmt -s -l -w $(SRCS)
|
||||
|
||||
# Release helper
|
||||
.PHONY: patch minor major detach
|
||||
|
||||
|
|
|
@ -38,9 +38,8 @@ type EnvLoader struct {
|
|||
}
|
||||
|
||||
func (l *EnvLoader) MainTest(m *testing.M) int {
|
||||
_, force := os.LookupEnv("LEGO_E2E_TESTS")
|
||||
if _, ci := os.LookupEnv("CI"); !ci && !force {
|
||||
fmt.Fprintln(os.Stderr, "skipping test: e2e tests are disabled. (no 'CI' or 'LEGO_E2E_TESTS' env var)")
|
||||
if _, e2e := os.LookupEnv("LEGO_E2E_TESTS"); !e2e {
|
||||
fmt.Fprintln(os.Stderr, "skipping test: e2e tests are disabled. (no 'LEGO_E2E_TESTS' env var)")
|
||||
fmt.Println("PASS")
|
||||
return 0
|
||||
}
|
||||
|
|
|
@ -8,13 +8,12 @@ import (
|
|||
func TestForTimeout(t *testing.T) {
|
||||
c := make(chan error)
|
||||
go func() {
|
||||
err := For("", 3*time.Second, 1*time.Second, func() (bool, error) {
|
||||
c <- For("", 3*time.Second, 1*time.Second, func() (bool, error) {
|
||||
return false, nil
|
||||
})
|
||||
c <- err
|
||||
}()
|
||||
|
||||
timeout := time.After(4 * time.Second)
|
||||
timeout := time.After(5 * time.Second)
|
||||
select {
|
||||
case <-timeout:
|
||||
t.Fatal("timeout exceeded")
|
||||
|
|
|
@ -3,6 +3,7 @@ package exec
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/go-acme/lego/v4/log"
|
||||
|
@ -37,7 +38,7 @@ func TestDNSProvider_Present(t *testing.T) {
|
|||
Mode: "",
|
||||
},
|
||||
expected: expected{
|
||||
args: "present _acme-challenge.domain. pW9ZKG0xz_PCriK-nCMOjADy9eJcgGWIzkkj2fN4uZM\n",
|
||||
args: "present _acme-challenge.domain. pW9ZKG0xz_PCriK-nCMOjADy9eJcgGWIzkkj2fN4uZM",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -55,7 +56,7 @@ func TestDNSProvider_Present(t *testing.T) {
|
|||
Mode: "RAW",
|
||||
},
|
||||
expected: expected{
|
||||
args: "present -- domain token keyAuth\n",
|
||||
args: "present -- domain token keyAuth",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -78,7 +79,7 @@ func TestDNSProvider_Present(t *testing.T) {
|
|||
require.Error(t, err)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, test.expected.args, message)
|
||||
assert.Equal(t, test.expected.args, strings.TrimSpace(message))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -110,7 +111,7 @@ func TestDNSProvider_CleanUp(t *testing.T) {
|
|||
Mode: "",
|
||||
},
|
||||
expected: expected{
|
||||
args: "cleanup _acme-challenge.domain. pW9ZKG0xz_PCriK-nCMOjADy9eJcgGWIzkkj2fN4uZM\n",
|
||||
args: "cleanup _acme-challenge.domain. pW9ZKG0xz_PCriK-nCMOjADy9eJcgGWIzkkj2fN4uZM",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -128,7 +129,7 @@ func TestDNSProvider_CleanUp(t *testing.T) {
|
|||
Mode: "RAW",
|
||||
},
|
||||
expected: expected{
|
||||
args: "cleanup -- domain token keyAuth\n",
|
||||
args: "cleanup -- domain token keyAuth",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -151,7 +152,7 @@ func TestDNSProvider_CleanUp(t *testing.T) {
|
|||
require.Error(t, err)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, test.expected.args, message)
|
||||
assert.Equal(t, test.expected.args, strings.TrimSpace(message))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -52,7 +52,8 @@ func TestNewDNSProvider(t *testing.T) {
|
|||
envGoogleApplicationCredentials: "not-a-secret-file",
|
||||
envMetadataHost: "http://lego.wtf", // defined here to avoid the client cache.
|
||||
},
|
||||
expected: "googlecloud: unable to get Google Cloud client: google: error getting credentials using GOOGLE_APPLICATION_CREDENTIALS environment variable: open not-a-secret-file: no such file or directory",
|
||||
// the error message varies according to the OS used.
|
||||
expected: "googlecloud: unable to get Google Cloud client: google: error getting credentials using GOOGLE_APPLICATION_CREDENTIALS environment variable: ",
|
||||
},
|
||||
{
|
||||
desc: "missing project",
|
||||
|
@ -95,7 +96,8 @@ func TestNewDNSProvider(t *testing.T) {
|
|||
require.NotNil(t, p.config)
|
||||
require.NotNil(t, p.client)
|
||||
} else {
|
||||
require.EqualError(t, err, test.expected)
|
||||
require.Error(t, err)
|
||||
require.Contains(t, err.Error(), test.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ func TestNewDNSProvider(t *testing.T) {
|
|||
EnvRegion: "us-phoenix-1",
|
||||
EnvCompartmentOCID: "123",
|
||||
},
|
||||
expected: "oraclecloud: can not create client, bad configuration: x509: decryption password incorrect",
|
||||
expected: "oraclecloud: can not create client, bad configuration: ",
|
||||
},
|
||||
{
|
||||
desc: "missing OCI_TENANCY_OCID",
|
||||
|
@ -191,7 +191,8 @@ func TestNewDNSProvider(t *testing.T) {
|
|||
require.NotNil(t, p.config)
|
||||
require.NotNil(t, p.client)
|
||||
} else {
|
||||
require.EqualError(t, err, test.expected)
|
||||
require.Error(t, err)
|
||||
require.Contains(t, err.Error(), test.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue