-
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.
Add PR Workflow, makefile, fix linter bug
- Loading branch information
Showing
4 changed files
with
103 additions
and
1 deletion.
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,44 @@ | ||
name: Pull request | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build docker image | ||
env: | ||
REF: ${{ github. sha }} | ||
run: make build | ||
|
||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 2 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: 'go.mod' | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v4 | ||
with: | ||
version: v1.55.2 | ||
|
||
test: | ||
name: Unit Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: 'go.mod' | ||
- name: Install dependencies | ||
run: go mod download | ||
- name: Run Tests | ||
run: go test -cover `go list ./... | grep -v 'pkg/client'` |
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,30 @@ | ||
FROM golang:1.22-alpine3.19 as builder | ||
|
||
RUN apk update && \ | ||
apk add bash jq alpine-sdk sed gawk git ca-certificates curl && \ | ||
apk add --no-cache gcc musl-dev | ||
|
||
# WORKDIR /go/src/ | ||
|
||
# get dependencies | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
# copy code | ||
COPY . . | ||
|
||
# Build project | ||
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w" -a -installsuffix cgo -o /radix-oauth-guard | ||
|
||
RUN addgroup -S -g 1000 guard | ||
RUN adduser -S -u 1000 -G guard guard | ||
|
||
FROM scratch | ||
|
||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
COPY --from=builder /etc/passwd /etc/passwd | ||
COPY --from=builder /radix-oauth-guard /radix-oauth-guard | ||
|
||
EXPOSE 8000 | ||
USER 1000 | ||
ENTRYPOINT ["/radix-oauth-guard"] |
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,29 @@ | ||
DOCKER_REGISTRY=radixdev.azurecr.io | ||
VERSION=latest | ||
BRANCH := $(shell git rev-parse --abbrev-ref HEAD) | ||
IMAGE_NAME=$(DOCKER_REGISTRY)/radix-oauth-guard:$(BRANCH)-$(VERSION) | ||
|
||
.PHONY: build | ||
build: | ||
docker build -t $(IMAGE_NAME) . | ||
|
||
.PHONY: push | ||
push: | ||
az acr login -n $(DOCKER_REGISTRY) | ||
docker push $(IMAGE_NAME) | ||
|
||
.PHONY: test | ||
test: | ||
go test -cover `go list ./... | grep -v 'pkg/client'` | ||
|
||
.PHONY: lint | ||
lint: bootstrap | ||
golangci-lint run --max-same-issues 0 | ||
|
||
|
||
HAS_GOLANGCI_LINT := $(shell command -v golangci-lint;) | ||
|
||
bootstrap: | ||
ifndef HAS_GOLANGCI_LINT | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2 | ||
endif |
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