Skip to content

Commit

Permalink
fix: add support for woodpecker CI (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
gkampitakis authored Oct 9, 2022
1 parent ea7ad60 commit e3636de
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
.PHONY: install-tools lint test test-verbose format
.PHONY: install-tools lint test test-verbose format help

install-tools:
# Install linting tools
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

install-tools: ## Install linting tools
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.49.0
go install mvdan.cc/gofumpt@latest
go install github.com/segmentio/golines@latest

lint:
lint: ## Run golangci linter
golangci-lint run -c ./golangci.yml ./...

format:
format: ## Format code
gofumpt -l -w -extra .
golines . -w

test:
test: ## Run tests
go test -race -test.timeout 120s -count=1 ./...

test-verbose:
test-verbose: ## Run tests with verbose output
go test -race -test.timeout 120s -v -cover -count=1 ./...
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Officially supported CI servers:
| [Travis CI](http://travis-ci.org) | `TRAVIS` ||
| [Vercel](https://vercel.com/) | `VERCEL` | 🚫 |
| [Visual Studio App Center](https://appcenter.ms/) | `APPCENTER` | 🚫 |
| [Woodpecker](https://woodpecker-ci.org/) | `ci.WOODPECKER` ||

## API

Expand Down
26 changes: 24 additions & 2 deletions ciinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TestCI(t *testing.T) {

initialize()

assertEqual(t, 40, len(vendors), "We should have 40 vendors")
assertEqual(t, 41, len(vendors), "We should have 41 vendors")
assertEqual(t, true, IsCI)
assertEqual(t, isActualPr(), IsPr)
assertEqual(t, "GitHub Actions", Name)
Expand Down Expand Up @@ -122,7 +122,6 @@ func TestCI(t *testing.T) {
assertEqual(t, "", Name)
assertEqual(t, false, IsVendor("CODESHIP"))
})

for _, scenario := range []TestScenario{
{
description: "AppVeyor - PR",
Expand Down Expand Up @@ -706,6 +705,29 @@ func TestCI(t *testing.T) {
setEnv(t, "XCS", "1")
},
},
{
description: "Woodpecker - PR",
expected: ScenarioExpected{
isPR: true,
name: "Woodpecker",
constant: "WOODPECKER",
},
setup: func(t *testing.T) {
setEnv(t, "CI", "woodpecker")
setEnv(t, "CI_BUILD_EVENT", "pull_request")
},
},
{
description: "Woodpecker",
expected: ScenarioExpected{
isPR: false,
name: "Woodpecker",
constant: "WOODPECKER",
},
setup: func(t *testing.T) {
setEnv(t, "CI", "woodpecker")
},
},
} {
t.Run(scenario.description, func(t *testing.T) {
scenario.setup(t)
Expand Down
6 changes: 6 additions & 0 deletions vendors.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,4 +351,10 @@ var vendors = []vendor{
constant: "XCODE_SERVER",
env: []env{{key: "XCS"}},
},
{
name: "Woodpecker",
constant: "WOODPECKER",
env: []env{{key: "CI", eq: "woodpecker"}},
pr: []pr{{key: "CI_BUILD_EVENT", eq: "pull_request"}},
},
}

0 comments on commit e3636de

Please sign in to comment.