mirror of
https://github.com/caddyserver/xcaddy.git
synced 2025-01-22 08:36:28 +01:00
Emit main.go contents to log; update CI (#95)
* Log out main.go contents * Ignore `caddy` binary when using `./xcaddy` for testing * Update CI, switch linter to match Caddy repo
This commit is contained in:
parent
58e714eb0e
commit
7d6084b6d7
6 changed files with 42 additions and 22 deletions
25
.github/workflows/ci.yml
vendored
25
.github/workflows/ci.yml
vendored
|
@ -1,6 +1,6 @@
|
||||||
# Used as inspiration: https://github.com/mvdan/github-actions-golang
|
# Used as inspiration: https://github.com/mvdan/github-actions-golang
|
||||||
|
|
||||||
name: Cross-Platform Tests
|
name: Tests
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
@ -17,7 +17,7 @@ jobs:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ ubuntu-latest, macos-latest, windows-latest ]
|
os: [ ubuntu-latest, macos-latest, windows-latest ]
|
||||||
go: [ '1.16', '1.17' ]
|
go: [ '1.17', '1.18' ]
|
||||||
|
|
||||||
# Set some variables per OS, usable via ${{ matrix.VAR }}
|
# Set some variables per OS, usable via ${{ matrix.VAR }}
|
||||||
# XCADDY_BIN_PATH: the path to the compiled xcaddy binary, for artifact publishing
|
# XCADDY_BIN_PATH: the path to the compiled xcaddy binary, for artifact publishing
|
||||||
|
@ -39,12 +39,12 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Print Go version and environment
|
- name: Print Go version and environment
|
||||||
id: vars
|
id: vars
|
||||||
|
@ -92,25 +92,12 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
go test -v -coverprofile="cover-profile.out" -short -race ./...
|
go test -v -coverprofile="cover-profile.out" -short -race ./...
|
||||||
|
|
||||||
# From https://github.com/reviewdog/action-golangci-lint
|
|
||||||
golangci-lint:
|
|
||||||
name: runner / golangci-lint
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code into the Go module directory
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Run golangci-lint
|
|
||||||
uses: reviewdog/action-golangci-lint@v1
|
|
||||||
# uses: docker://reviewdog/action-golangci-lint:v1 # pre-build docker image
|
|
||||||
with:
|
|
||||||
github_token: ${{ secrets.github_token }}
|
|
||||||
|
|
||||||
goreleaser-check:
|
goreleaser-check:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- uses: goreleaser/goreleaser-action@v2
|
- uses: goreleaser/goreleaser-action@v2
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
|
|
27
.github/workflows/lint.yml
vendored
Normal file
27
.github/workflows/lint.yml
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
name: Lint
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# From https://github.com/golangci/golangci-lint-action
|
||||||
|
golangci:
|
||||||
|
name: lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: 1.17
|
||||||
|
|
||||||
|
- name: golangci-lint
|
||||||
|
uses: golangci/golangci-lint-action@v3
|
||||||
|
with:
|
||||||
|
version: v1.44
|
||||||
|
# Optional: show only new issues if it's a pull request. The default value is `false`.
|
||||||
|
# only-new-issues: true
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
|
@ -11,7 +11,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ ubuntu-latest ]
|
os: [ ubuntu-latest ]
|
||||||
go: [ '1.17' ]
|
go: [ '1.18' ]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,6 +4,8 @@ _gitignore/
|
||||||
# build artifacts
|
# build artifacts
|
||||||
cmd/xcaddy/xcaddy
|
cmd/xcaddy/xcaddy
|
||||||
cmd/xcaddy/xcaddy.exe
|
cmd/xcaddy/xcaddy.exe
|
||||||
|
cmd/xcaddy/caddy
|
||||||
|
cmd/xcaddy/caddy.exe
|
||||||
|
|
||||||
# mac
|
# mac
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
|
@ -40,3 +40,7 @@ issues:
|
||||||
- text: "G204" # G204: Audit use of command execution
|
- text: "G204" # G204: Audit use of command execution
|
||||||
linters:
|
linters:
|
||||||
- gosec
|
- gosec
|
||||||
|
# we're writing out the main.go to a temp dir, not sensitive
|
||||||
|
- text: "G306" # G306: Expect WriteFile permissions to be 0600 or less (gosec)
|
||||||
|
linters:
|
||||||
|
- gosec
|
||||||
|
|
|
@ -83,7 +83,7 @@ func (b Builder) newEnvironment(ctx context.Context) (*environment, error) {
|
||||||
|
|
||||||
// write the main module file to temporary folder
|
// write the main module file to temporary folder
|
||||||
mainPath := filepath.Join(tempFolder, "main.go")
|
mainPath := filepath.Join(tempFolder, "main.go")
|
||||||
log.Printf("[INFO] Writing main module: %s", mainPath)
|
log.Printf("[INFO] Writing main module: %s\n%s", mainPath, buf.Bytes())
|
||||||
err = ioutil.WriteFile(mainPath, buf.Bytes(), 0644)
|
err = ioutil.WriteFile(mainPath, buf.Bytes(), 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -230,7 +230,7 @@ func (env environment) runCommand(ctx context.Context, cmd *exec.Cmd, timeout ti
|
||||||
// to the child process, so wait for it to die
|
// to the child process, so wait for it to die
|
||||||
select {
|
select {
|
||||||
case <-time.After(15 * time.Second):
|
case <-time.After(15 * time.Second):
|
||||||
cmd.Process.Kill()
|
_ = cmd.Process.Kill()
|
||||||
case <-cmdErrChan:
|
case <-cmdErrChan:
|
||||||
}
|
}
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
|
|
Loading…
Reference in a new issue