-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fix pipeline, add codeql, add goreleaser
- Loading branch information
1 parent
4b6b799
commit fe12816
Showing
5 changed files
with
332 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: 'CodeQL' | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * 0' | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: ['go'] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v1 | ||
with: | ||
languages: ${{ matrix.language }} | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
name: SOD | ||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cancel previous builds | ||
uses: styfle/cancel-workflow-action@0.7.0 | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.16 | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/go/pkg/mod | ||
~/.cache/go-build | ||
key: ${{ runner.os }}-go-test-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go-test- | ||
${{ runner.os }}-go- | ||
- name: Unit tests | ||
run: go test -count=1 -race -timeout=10m ./... -coverprofile=coverage.out | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cancel previous builds | ||
uses: styfle/cancel-workflow-action@0.7.0 | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.16 | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/go/pkg/mod | ||
~/.cache/go-build | ||
key: ${{ runner.os }}-go-test-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go-test- | ||
${{ runner.os }}-go- | ||
- name: go-lint | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
version: 'v1.40.1' | ||
skip-go-installation: true | ||
skip-pkg-cache: true | ||
skip-build-cache: true | ||
|
||
build-verify: | ||
needs: [ lint, test ] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Cancel previous builds | ||
uses: styfle/cancel-workflow-action@0.7.0 | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.16 | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/go/pkg/mod | ||
~/.cache/go-build | ||
key: ${{ runner.os }}-go-test-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go-test- | ||
${{ runner.os }}-go- | ||
- name: Build | ||
run: go build ./cmd/sod-srv | ||
|
||
build-binary: | ||
needs: build-verify | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Cancel previous builds | ||
uses: styfle/cancel-workflow-action@0.7.0 | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.16 | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/go/pkg/mod | ||
~/.cache/go-build | ||
key: ${{ runner.os }}-go-test-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go-test- | ||
${{ runner.os }}-go- | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
version: latest | ||
args: release --config .goreleaser.yml --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Upload assets | ||
uses: actions/upload-artifact@v2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
name: sod | ||
path: dist/* | ||
|
||
docker-push: | ||
needs: build-verify | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Cancel previous builds | ||
uses: styfle/cancel-workflow-action@0.7.0 | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.16 | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/go/pkg/mod | ||
~/.cache/go-build | ||
key: ${{ runner.os }}-go-test-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go-test- | ||
${{ runner.os }}-go- | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: | | ||
robotomize/sod:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
before: | ||
hooks: | ||
- go mod download | ||
- go generate ./... | ||
builds: | ||
- id: sod | ||
main: ./cmd/sod-srv | ||
binary: sod | ||
env: | ||
- CGO_ENABLED=0 | ||
- GO111MODULE=on | ||
goos: | ||
- freebsd | ||
- linux | ||
- windows | ||
- darwin | ||
ldflags: | ||
- -s -w -X main.version={{.Version}} -extldflags '-static' | ||
archives: | ||
- id: sod | ||
builds: | ||
- sod | ||
name_template: "sod_{{ .Version }}_{{ .Os }}_{{ .Arch }}" | ||
replacements: | ||
darwin: MacOSX | ||
linux: Linux | ||
windows: Windows | ||
amd64: x86_64 | ||
|
||
nfpms: | ||
- vendor: sod | ||
homepage: https://github.com/go-sod/sod | ||
maintainer: Nikita Ivanov | ||
description: Recognition of anomalies in the data stream in real time. Identify peaks. Fraud detection. | ||
license: MIT | ||
formats: [ deb, rpm ] | ||
checksum: | ||
name_template: 'checksums.txt' | ||
snapshot: | ||
name_template: "{{ .Tag }}" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
release: | ||
github: | ||
owner: go-sod | ||
name: sod |
Oops, something went wrong.