Skip to content

Commit 325d8bc

Browse files
committed
Merge branch 'master' into name-constraints
2 parents debe565 + d46c5b2 commit 325d8bc

File tree

128 files changed

+1308
-1288
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+1308
-1288
lines changed

Diff for: .github/workflows/codeql-analysis.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ on:
1818
# The branches below must be a subset of the branches above
1919
branches: [ "master" ]
2020
schedule:
21-
- cron: '30 3 * * 3'
21+
- cron: '0 0 * * *'
22+
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
25+
cancel-in-progress: true
2226

2327
jobs:
2428
analyze:
@@ -48,11 +52,11 @@ jobs:
4852
# If you wish to specify custom queries, you can do so here or in a config file.
4953
# By default, queries listed here will override any specified in a config file.
5054
# Prefix the list here with "+" to use these queries and those in the config file.
51-
55+
5256
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
5357
# queries: security-extended,security-and-quality
5458

55-
59+
5660
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5761
# If this step fails, then you should remove it and run the build manually (see below)
5862
- name: Autobuild
@@ -61,7 +65,7 @@ jobs:
6165
# ℹ️ Command-line programs to run using the OS shell.
6266
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
6367

64-
# If the Autobuild fails above, remove it and uncomment the following three lines.
68+
# If the Autobuild fails above, remove it and uncomment the following three lines.
6569
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
6670

6771
# - run: |

Diff for: .github/workflows/release.yml

+5-33
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,13 @@ on:
77
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
88

99
jobs:
10-
test:
11-
name: Lint, Test, Build
12-
runs-on: ubuntu-20.04
13-
strategy:
14-
matrix:
15-
go: [ '1.18', '1.19' ]
16-
outputs:
17-
is_prerelease: ${{ steps.is_prerelease.outputs.IS_PRERELEASE }}
18-
steps:
19-
-
20-
name: Checkout
21-
uses: actions/checkout@v2
22-
-
23-
name: Setup Go
24-
uses: actions/setup-go@v2
25-
with:
26-
go-version: ${{ matrix.go }}
27-
-
28-
name: Install Deps
29-
id: install-deps
30-
run: sudo apt-get -y install libpcsclite-dev
31-
-
32-
name: golangci-lint
33-
uses: golangci/golangci-lint-action@v2
34-
with:
35-
version: ${{ secrets.GOLANGCI_LINT_VERSION }}
36-
args: --timeout=30m
37-
-
38-
name: Test, Build
39-
id: lint_test_build
40-
run: V=1 make ci
10+
ci:
11+
uses: smallstep/workflows/.github/workflows/goCI.yml@main
12+
4113

4214
create_release:
4315
name: Create Release
44-
needs: test
16+
needs: ci
4517
runs-on: ubuntu-20.04
4618
outputs:
4719
debversion: ${{ steps.extract-tag.outputs.DEB_VERSION }}
@@ -132,7 +104,7 @@ jobs:
132104
build_upload_docker:
133105
name: Build & Upload Docker Images
134106
runs-on: ubuntu-20.04
135-
needs: test
107+
needs: ci
136108
steps:
137109
-
138110
name: Checkout

Diff for: .github/workflows/test.yml

+9-39
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Lint, Test, Build
1+
name: CI
22

33
on:
44
push:
@@ -7,43 +7,13 @@ on:
77
branches:
88
- "**"
99
pull_request:
10+
schedule:
11+
- cron: '0 0 * * *'
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
15+
cancel-in-progress: true
1016

1117
jobs:
12-
lintTestBuild:
13-
name: Lint, Test, Build
14-
runs-on: ubuntu-20.04
15-
strategy:
16-
matrix:
17-
go: [ '1.18', '1.19' ]
18-
steps:
19-
-
20-
name: Checkout
21-
uses: actions/checkout@v2
22-
-
23-
name: Setup Go
24-
uses: actions/setup-go@v2
25-
with:
26-
go-version: ${{ matrix.go }}
27-
-
28-
name: Install Deps
29-
id: install-deps
30-
run: sudo apt-get -y install libpcsclite-dev
31-
-
32-
name: golangci-lint
33-
uses: golangci/golangci-lint-action@v2
34-
with:
35-
version: ${{ secrets.GOLANGCI_LINT_VERSION }}
36-
args: --timeout=30m
37-
-
38-
name: Test, Build
39-
id: lint_test_build
40-
run: V=1 make ci
41-
-
42-
name: Codecov
43-
if: matrix.go == '1.19'
44-
uses: codecov/codecov-action@v2
45-
with:
46-
token: ${{ secrets.CODECOV_TOKEN }}
47-
files: ./coverage.out # optional
48-
name: codecov-umbrella # optional
49-
fail_ci_if_error: true # optional (default = false)
18+
ci:
19+
uses: smallstep/workflows/.github/workflows/goCI.yml@main

Diff for: .golangci.yml

-74
This file was deleted.

Diff for: Makefile

+12-11
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ ci: testcgo build
2828
#########################################
2929

3030
bootstra%:
31-
# Using a released version of golangci-lint to take into account custom replacements in their go.mod
32-
$Q curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.42.0
31+
$Q curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin latest
32+
$Q go install golang.org/x/vuln/cmd/govulncheck@latest
33+
$Q go install gotest.tools/gotestsum@latest
3334

3435
.PHONY: bootstra%
3536

@@ -132,17 +133,18 @@ generate:
132133
# Test
133134
#########################################
134135
test:
135-
$Q $(GOFLAGS) go test -short -coverprofile=coverage.out ./...
136+
$Q $(GOFLAGS) gotestsum -- -coverprofile=coverage.out -short -covermode=atomic ./...
137+
136138

137139
testcgo:
138-
$Q go test -short -coverprofile=coverage.out ./...
140+
$Q gotestsum -- -coverprofile=coverage.out -short -covermode=atomic ./...
139141

140142
.PHONY: test testcgo
141143

142144
integrate: integration
143145

144146
integration: bin/$(BINNAME)
145-
$Q $(GOFLAGS) go test -tags=integration ./integration/...
147+
$Q $(GOFLAGS) gotestsum -- -tags=integration ./integration/...
146148

147149
.PHONY: integrate integration
148150

@@ -151,15 +153,14 @@ integration: bin/$(BINNAME)
151153
#########################################
152154

153155
fmt:
154-
$Q gofmt -l -s -w $(SRC)
156+
$Q goimports -l -w $(SRC)
155157

158+
lint: SHELL:=/bin/bash
156159
lint:
157-
$Q golangci-lint run --timeout=30m
158-
159-
lintcgo:
160-
$Q LOG_LEVEL=error golangci-lint run --timeout=30m
160+
$Q LOG_LEVEL=error golangci-lint run --config <(curl -s https://raw.githubusercontent.com/smallstep/workflows/master/.golangci.yml) --timeout=30m
161+
$Q govulncheck ./...
161162

162-
.PHONY: fmt lint lintcgo
163+
.PHONY: fmt lint
163164

164165
#########################################
165166
# Install

Diff for: acme/account.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func (a *Account) ToLog() (interface{}, error) {
3333

3434
// IsValid returns true if the Account is valid.
3535
func (a *Account) IsValid() bool {
36-
return Status(a.Status) == StatusValid
36+
return a.Status == StatusValid
3737
}
3838

3939
// KeyToID converts a JWK to a thumbprint.

Diff for: acme/account_test.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ func TestKeyToID(t *testing.T) {
4646
tc := run(t)
4747
if id, err := KeyToID(tc.jwk); err != nil {
4848
if assert.NotNil(t, tc.err) {
49-
switch k := err.(type) {
50-
case *Error:
49+
var k *Error
50+
if errors.As(err, &k) {
5151
assert.Equals(t, k.Type, tc.err.Type)
5252
assert.Equals(t, k.Detail, tc.err.Detail)
5353
assert.Equals(t, k.Status, tc.err.Status)
5454
assert.Equals(t, k.Err.Error(), tc.err.Err.Error())
5555
assert.Equals(t, k.Detail, tc.err.Detail)
56-
default:
56+
} else {
5757
assert.FatalError(t, errors.New("unexpected error type"))
5858
}
5959
}
@@ -131,12 +131,13 @@ func TestExternalAccountKey_BindTo(t *testing.T) {
131131
}
132132
if wantErr {
133133
assert.NotNil(t, err)
134-
assert.Type(t, &Error{}, err)
135-
ae, _ := err.(*Error)
136-
assert.Equals(t, ae.Type, tt.err.Type)
137-
assert.Equals(t, ae.Detail, tt.err.Detail)
138-
assert.Equals(t, ae.Identifier, tt.err.Identifier)
139-
assert.Equals(t, ae.Subproblems, tt.err.Subproblems)
134+
var ae *Error
135+
if assert.True(t, errors.As(err, &ae)) {
136+
assert.Equals(t, ae.Type, tt.err.Type)
137+
assert.Equals(t, ae.Detail, tt.err.Detail)
138+
assert.Equals(t, ae.Identifier, tt.err.Identifier)
139+
assert.Equals(t, ae.Subproblems, tt.err.Subproblems)
140+
}
140141
} else {
141142
assert.Equals(t, eak.AccountID, acct.ID)
142143
assert.Equals(t, eak.HmacKey, []byte{})

Diff for: acme/api/account.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package api
22

33
import (
44
"encoding/json"
5+
"errors"
56
"net/http"
67

78
"github.com/go-chi/chi"
@@ -97,8 +98,8 @@ func NewAccount(w http.ResponseWriter, r *http.Request) {
9798
httpStatus := http.StatusCreated
9899
acc, err := accountFromContext(ctx)
99100
if err != nil {
100-
acmeErr, ok := err.(*acme.Error)
101-
if !ok || acmeErr.Status != http.StatusBadRequest {
101+
var acmeErr *acme.Error
102+
if !errors.As(err, &acmeErr) || acmeErr.Status != http.StatusBadRequest {
102103
// Something went wrong ...
103104
render.Error(w, err)
104105
return

Diff for: acme/api/account_test.go

+12-10
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,12 @@ func TestNewAccountRequest_Validate(t *testing.T) {
197197
t.Run(name, func(t *testing.T) {
198198
if err := tc.nar.Validate(); err != nil {
199199
if assert.NotNil(t, err) {
200-
ae, ok := err.(*acme.Error)
201-
assert.True(t, ok)
202-
assert.HasPrefix(t, ae.Error(), tc.err.Error())
203-
assert.Equals(t, ae.StatusCode(), tc.err.StatusCode())
204-
assert.Equals(t, ae.Type, tc.err.Type)
200+
var ae *acme.Error
201+
if assert.True(t, errors.As(err, &ae)) {
202+
assert.HasPrefix(t, ae.Error(), tc.err.Error())
203+
assert.Equals(t, ae.StatusCode(), tc.err.StatusCode())
204+
assert.Equals(t, ae.Type, tc.err.Type)
205+
}
205206
}
206207
} else {
207208
assert.Nil(t, tc.err)
@@ -268,11 +269,12 @@ func TestUpdateAccountRequest_Validate(t *testing.T) {
268269
t.Run(name, func(t *testing.T) {
269270
if err := tc.uar.Validate(); err != nil {
270271
if assert.NotNil(t, err) {
271-
ae, ok := err.(*acme.Error)
272-
assert.True(t, ok)
273-
assert.HasPrefix(t, ae.Error(), tc.err.Error())
274-
assert.Equals(t, ae.StatusCode(), tc.err.StatusCode())
275-
assert.Equals(t, ae.Type, tc.err.Type)
272+
var ae *acme.Error
273+
if assert.True(t, errors.As(err, &ae)) {
274+
assert.HasPrefix(t, ae.Error(), tc.err.Error())
275+
assert.Equals(t, ae.StatusCode(), tc.err.StatusCode())
276+
assert.Equals(t, ae.Type, tc.err.Type)
277+
}
276278
}
277279
} else {
278280
assert.Nil(t, tc.err)

0 commit comments

Comments
 (0)