Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,8 @@ jobs:
run: |
set -ex

RELEASE_VERSION=$RELEASE_VERSION make deps
RELEASE_VERSION=$RELEASE_VERSION make build build-strip

ln -s auth gotrue
tar -czvf auth-v$RELEASE_VERSION-x86.tar.gz auth gotrue migrations/
mv auth-arm64 auth
tar -czvf auth-v$RELEASE_VERSION-arm64.tar.gz auth gotrue migrations/

mv auth-darwin-arm64 auth
tar -czvf auth-v$RELEASE_VERSION-darwin-arm64.tar.gz auth gotrue migrations/

mv auth-arm64-strip auth
tar -cf - auth gotrue migrations/ | xz -T0 -9e -C crc64 > auth-v$RELEASE_VERSION-arm64.tar.xz
MAKE_JOBS="$(nproc 2>/dev/null || echo 4)"
RELEASE_VERSION=$RELEASE_VERSION make -j"$MAKE_JOBS" release

- name: Generate checksums
if: ${{ steps.release.outputs.release_created == 'true' || steps.release.outputs.prs_created == 'true' }}
Expand Down
25 changes: 7 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,17 @@ jobs:
then
echo 'Make sure to run "gofmt -s -w ." before commit!' && exit 1
fi
- name: Check go vet
run: |
set -x
go vet ./...
- name: Run static check
run: |
set -x
make static
- name: Check gosec
run: |
set -x
make sec
- name: Run govulncheck
run: |
set -x
make vulncheck
- name: Init Database
run: psql -f hack/init_postgres.sql postgresql://postgres:root@localhost:5432/postgres
- name: Run migrations
run: make migrate_dev
- name: Lint and test
run: make test
- name: Run linters and tests
run: |
set -x

MAKE_JOBS="$(nproc 2>/dev/null || echo 4)"
make -j"$MAKE_JOBS" release-test

- name: Cleanup coverage
run: |
set -x
Expand Down
80 changes: 67 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,51 +1,98 @@
.PHONY: all build deps image migrate test vet sec vulncheck format unused
.PHONY: all build deps image migrate test vet sec vulncheck format unused release
.PHONY: check-gosec check-govulncheck check-oapi-codegen check-staticcheck
CHECK_FILES?=./...
CHECK_FILES ?= ./...

ifdef RELEASE_VERSION
VERSION=v$(RELEASE_VERSION)
else
VERSION=$(shell git describe --tags)
endif

FLAGS=-ldflags "-X github.com/supabase/auth/internal/utilities.Version=$(VERSION)" -buildvcs=false
FLAGS = -ldflags "-X github.com/supabase/auth/internal/utilities.Version=$(VERSION)" -buildvcs=false

ifneq ($(shell docker compose version 2>/dev/null),)
DOCKER_COMPOSE=docker compose
DOCKER_COMPOSE = docker compose
else
DOCKER_COMPOSE=docker-compose
DOCKER_COMPOSE = docker-compose
endif

DEV_DOCKER_COMPOSE:=docker-compose-dev.yml
DEV_DOCKER_COMPOSE = docker-compose-dev.yml

RELEASE_TARGETS = x86 arm64 darwin-arm64 arm64-strip
RELEASE_ARCHIVES = \
auth-$(VERSION)-x86.tar.gz \
auth-$(VERSION)-arm64.tar.gz \
auth-$(VERSION)-darwin-arm64.tar.gz \
auth-$(VERSION)-arm64.tar.xz


help: ## Show this help.
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

all: vet sec static build ## Run the tests and build the binary.

build: deps ## Build the binary.
CGO_ENABLED=0 go build $(FLAGS)
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build $(FLAGS) -o auth-arm64
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build $(FLAGS) -o auth-darwin-arm64
build: auth auth-arm64 auth-darwin-arm64 ## Build the binaries.

build-strip: auth-arm64-strip ## Build a stripped binary, for which the version file needs to be rewritten.

auth: deps
CGO_ENABLED=0 go build $(FLAGS) -o $(@)

build-strip: deps ## Build a stripped binary, for which the version file needs to be rewritten.
auth-x86: deps
CGO_ENABLED=0 GOARCH=amd64 go build $(FLAGS) -o $(@)

auth-arm64: deps
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build $(FLAGS) -o $(@)

auth-darwin-arm64: deps
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build $(FLAGS) -o $(@)

auth-arm64-strip: deps
echo "package utilities" > internal/utilities/version.go
echo "const Version = \"$(VERSION)\"" >> internal/utilities/version.go

CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build \
$(FLAGS) -ldflags "-s -w" -o auth-arm64-strip
$(FLAGS) -ldflags "-s -w" -o $(@)

deps: ## Install dependencies.
@go mod download
@go mod verify


release-test: \
vet \
static \
sec \
vulncheck \
test

release: $(RELEASE_ARCHIVES)

auth-$(VERSION)-%.tar.gz: \
release-%/auth \
release-%/gotrue | migrations
tar -C $(<D) -czvf $(@) auth gotrue -C ../ migrations/

auth-$(VERSION)-arm64.tar.xz: \
release-arm64-strip/auth \
release-arm64-strip/gotrue | migrations
tar -C $(<D) -cf - auth gotrue -C ../ migrations/ \
| xz -T0 -9e -C crc64 > $(@)

release-%/auth: auth-%
mkdir -p $(@D)
cp -a $(<) $(@)

release-%/gotrue: release-%/auth
ln -sf $(<F) $(@)

migrate_dev: ## Run database migrations for development.
hack/migrate.sh postgres

migrate_test: ## Run database migrations for test.
hack/migrate.sh postgres

test: build ## Run tests.
test: auth ## Run tests.
go test $(CHECK_FILES) -coverprofile=coverage.out -coverpkg ./... -p 1 -race -v -count=1
./hack/coverage.sh

Expand Down Expand Up @@ -112,3 +159,10 @@ docker-clean: ## Remove the development containers and volumes

format:
gofmt -s -w .

clean:
rm -rf \
$(addprefix release-,$(RELEASE_TARGETS)) \
$(addprefix auth-,$(RELEASE_TARGETS)) \
$(RELEASE_ARCHIVES) \
auth
Loading