Skip to content

Commit

Permalink
Merge pull request #1 from goto/fix-ci
Browse files Browse the repository at this point in the history
fix: ci using goreleaser and github
  • Loading branch information
mabdh authored Mar 2, 2024
2 parents 9091db6 + 530c776 commit fa78d31
Show file tree
Hide file tree
Showing 22 changed files with 560 additions and 194 deletions.
74 changes: 0 additions & 74 deletions .circleci/config.yml

This file was deleted.

17 changes: 17 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Lint
on: [push, workflow_dispatch]

jobs:
golangci-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.21
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
skip-go-installation: true
version: v1.54.2
args: --timeout=10m
39 changes: 39 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: release

on:
push:
tags:
- "v*.*.*"
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.21
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Test
run: make test
- name: Get release tag
id: get_version
uses: battila7/get-version-action@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GO_RELEASER_TOKEN }}
24 changes: 24 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Test
on: [push]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Set up Go 1.21
uses: actions/setup-go@v2
with:
go-version: 1.21
id: go
- name: Install dependencies
run: sudo apt-get install build-essential
- name: Install packages
run: go mod tidy
- name: Run Test
run: make test
- name: Send coverage to coveralls
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ out/
*.swp
.idea/*
iap.conf.toml
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
linters:
disable:
- errcheck
93 changes: 76 additions & 17 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,83 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
project_name: iap_auth

release:
draft: true
prerelease: auto
name_template: "{{.ProjectName}}-v{{.Version}}"

before:
hooks:
- go mod tidy
- go mod vendor

builds:
- env:
- CGO_ENABLED=0
- GO111MODULE=on
- main: ./main.go
id: "iap_auth"
binary: iap_auth
flags:
- -a
ldflags:
- -s -w -X github.com/goto/iap_auth/config.Version={{.Tag}} -X github.com/goto/iap_auth/config.BuildCommit={{.FullCommit}} -X github.com/goto/iap_auth/config.BuildDate={{.Date}}
env:
- CGO_ENABLED=0
goos: [darwin, linux, windows]
goarch: [amd64, 386]


archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
- name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else if eq .Arch "windows" }}windows
{{- else if eq .Arch "linux" }}linux
{{- else if eq .Arch "darwin" }}macos
{{- else }}{{ .Arch }}{{ end }}
format_overrides:
- goos: windows
format: zip
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- "^docs:"
- "^test:"
- "^build:"
- "Merge pull request"
- "Merge branch"

checksum:
name_template: "checksums.txt"

snapshot:
name_template: "{{ .Tag }}-next"

dockers:
- goos: linux
goarch: amd64
ids:
- iap_auth
dockerfile: Dockerfile
image_templates:
- "docker.io/gotocompany/{{.ProjectName}}:latest"
- "docker.io/gotocompany/{{.ProjectName}}:{{ .Version }}"
- "docker.io/gotocompany/{{.ProjectName}}:{{ .Tag }}-amd64"

brews:
- name: iap_auth
homepage: "https://github.com/goto/iap_auth"
description: "Accessing service behind IAP."
repository:
owner: goto
name: homebrew-taps
license: "Apache 2.0"
folder: Formula
dependencies:
- name: git
install: |-
bin.install "iap_auth"
commit_author:
name: github-actions[bot]
email: 41898282+github-actions[bot]@users.noreply.github.com
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM alpine:3.9
FROM alpine:3.13

RUN apk --update upgrade && \
apk add curl ca-certificates && \
update-ca-certificates && \
rm -rf /var/cache/apk/*

ADD ./out/iap_auth .
COPY iap_auth .

ENV PORT=8081 \
LOGGER_LEVEL=INFO \
Expand All @@ -14,4 +14,4 @@ ENV PORT=8081 \
SERVICE_ACCOUNT_CREDENTIALS= \
CLIENT_ID=
EXPOSE ${PORT}
CMD ./iap_auth
ENTRYPOINT ["./iap_auth"]
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,11 @@ fmt:
vet:
go vet ./...

lint:
@if [[ `golint $(All_PACKAGES) | { grep -vwE "exported (var|function|method|type|const) \S+ should have comment" || true; } | wc -l | tr -d ' '` -ne 0 ]]; then \
golint $(ALL_PACKAGES) | { grep -vwE "exported (var|function|method|type|const) \S+ should have comment" || true; }; \
exit 2; \
fi;
lint: ## lint checker
golangci-lint run

test: copy-config
go test ./...
go test -race $(shell go list ./... | grep -v /test/) -covermode=atomic -coverprofile=coverage.out

test-cover-html:
@echo "mode: count" > coverage-all.out
Expand Down
46 changes: 36 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
module github.com/gojekfarm/iap_auth
module github.com/goto/iap_auth

go 1.21.6

require (
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2
github.com/sirupsen/logrus v1.9.3
github.com/spf13/viper v1.18.2
github.com/stretchr/testify v1.8.4
golang.org/x/oauth2 v0.17.0
)

require (
github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf
github.com/golang/lint v0.0.0-20181217174547-8f45f776aaf1 // indirect
github.com/sirupsen/logrus v1.3.0
github.com/spf13/viper v1.3.1
github.com/stretchr/testify v1.2.2
golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1 // indirect
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e
golang.org/x/oauth2 v0.0.0-20190130055435-99b60b757ec1
golang.org/x/tools v0.0.0-20190202235157-7414d4c1f71c // indirect
cloud.google.com/go/compute v1.24.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit fa78d31

Please sign in to comment.