name: Go on: push: branches: - master - develop pull_request: branches: - master - develop jobs: lint: name: Linter runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: go-version: '^1.15' - name: Get the current branch name shell: bash run: | echo "::set-output name=branch::${GITHUB_REF#refs/heads/}" echo "::set-output name=branch_head::${GITHUB_HEAD_REF#refs/heads/}" id: getref # nektos/act does not have sudo install but we need it on GH actions so # try to install it. - name: Install sudo run: bash -c "apt-get update || true ; apt-get install sudo || true" env: DEBIAN_FRONTEND: noninteractive - name: Install git and gcc run: sudo bash -c "apt-get update && apt-get install -y git gcc libc6-dev" env: DEBIAN_FRONTEND: noninteractive - name: Run golangci-lint uses: golangci/golangci-lint-action@v2 with: version: v1.29 only-new-issues: true args: -c ./.golangci.yml skip-go-installation: true - name: Maybe update development dependencies shell: bash run: | if [[ $BRANCHES != *"master"* ]]; then echo "::debug::updating development dependencies" export GOPROXY=direct export GOSUMDB=off go get -u -v github.com/safing/portbase@develop go get -u -v github.com/safing/spn@develop else echo "::debug::not updating development dependencies; master branch" fi env: BRANCHES: "${{ steps.getref.outputs.branch }} ${{ steps.getref.outputs.branch_head }}" - name: Get dependencies run: go mod download - name: Run go vet run: go vet ./... - name: Install golint run: bash -c "GOBIN=$(pwd) go get -u golang.org/x/lint/golint" - name: Run golint run: ./golint -set_exit_status -min_confidence 1.0 ./... - name: Run gofmt run: bash -c "test -z $(gofmt -s -l .)" test: name: Test runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: go-version: '^1.15' - name: Update development dependencies shell: bash run: | if [[ $BRANCHES != *"master"* ]]; then echo "::debug::updating development dependencies" export GOPROXY=direct export GOSUMDB=off go get -u -v github.com/safing/portbase@develop go get -u -v github.com/safing/spn@develop else echo "::debug::not updating development dependencies; master branch" fi env: BRANCHES: "${{ steps.getref.outputs.branch }} ${{ steps.getref.outputs.branch_head }}" # nektos/act does not have sudo install but we need it on GH actions so # try to install it. - name: Install sudo run: bash -c "apt-get update || true ; apt-get install sudo || true" env: DEBIAN_FRONTEND: noninteractive - name: Install git and gcc run: sudo bash -c "apt-get update && apt-get install -y git gcc libc6-dev" env: DEBIAN_FRONTEND: noninteractive - name: Get dependencies run: go mod download - name: Test run: ./test --test-only