-
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.
Closes: #6
- Loading branch information
Showing
1,314 changed files
with
218 additions
and
468,759 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,73 @@ | ||
--- | ||
name: CI/CD | ||
on: | ||
pull_request: {} | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
golang-ci: | ||
name: Go Lang CI | ||
runs-on: ubuntu-latest | ||
env: | ||
docker-compose-service: golang-devtools | ||
XDG_CACHE_HOME: ${{ github.workspace }}/.cache/xdg | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- id: xdg_cache_hash | ||
run: echo "xdg_cache_hash=${{hashFiles('./docker-compose.yml', './docker-compose/Dockerfile', './go.sum')}}" >> $GITHUB_OUTPUT | ||
- name: Cache xdg | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ env.XDG_CACHE_HOME }} | ||
key: xdg-${{ github.repository }}-${{ github.job }}-${{ steps.xdg_cache_hash.outputs.xdg_cache_hash }} | ||
restore-keys: | | ||
xdg-${{ github.repository }}-${{ github.job }}-${{ steps.xdg_cache_hash.outputs.xdg_cache_hash }} | ||
xdg-${{ github.repository }}-${{ github.job }}- | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Configure access to internal and private GitHub repos | ||
run: git config --global url."https://${{ secrets.REVIEWBOT_GITHUB_TOKEN }}:[email protected]/coopnorge".insteadOf "https://github.com/coopnorge" | ||
- name: Build devtools | ||
run: docker compose build | ||
- name: Validate | ||
run: docker compose run --rm ${{ env.docker-compose-service }} validate VERBOSE=all | ||
|
||
validate-old-go: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
go: [ '1.20', '1.21' ] | ||
name: Go ${{ matrix.go }} - validate | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
- name: Install toolchain | ||
run: make toolchain | ||
- name: Validate | ||
run: make validate | ||
|
||
build: | ||
needs: | ||
- golang-ci | ||
- validate-old-go | ||
if: always() | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: exit 1 | ||
name: "Catch errors" | ||
if: | | ||
needs.golang-ci.result == 'failure' || | ||
needs.validate-old-go.result == 'failure' |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,76 @@ | ||
# vim: set noexpandtab fo-=t: | ||
# https://www.gnu.org/software/make/manual/make.html | ||
.PHONY: default | ||
default: | ||
|
||
######################################################################## | ||
# boiler plate | ||
######################################################################## | ||
SHELL=bash | ||
current_makefile:=$(lastword $(MAKEFILE_LIST)) | ||
current_makefile_dirname:=$(dir $(current_makefile)) | ||
current_makefile_dirname_abspath:=$(dir $(abspath $(current_makefile))) | ||
current_makefile_dirname_realpath:=$(dir $(realpath $(current_makefile))) | ||
|
||
ifneq ($(filter all vars,$(VERBOSE)),) | ||
dump_var=$(info var $(1)=$($(1))) | ||
dump_vars=$(foreach var,$(1),$(call dump_var,$(var))) | ||
else | ||
dump_var= | ||
dump_vars= | ||
endif | ||
|
||
ifneq ($(filter all targets,$(VERBOSE)),) | ||
__ORIGINAL_SHELL:=$(SHELL) | ||
SHELL=$(warning Building $@$(if $<, (from $<))$(if $?, ($? newer)))$(TIME) $(__ORIGINAL_SHELL) | ||
endif | ||
|
||
define __newline | ||
|
||
|
||
endef | ||
|
||
|
||
skip= | ||
# skipable makes the targets passed to it skipable with skip=foo% | ||
# $(1): targets that should be skipable | ||
skipable=$(filter-out $(skip),$(1)) | ||
|
||
go_install=GOFLAGS= go install $(if $(filter all commands,$(VERBOSE)),-v) $(go_install_flags) | ||
|
||
######################################################################## | ||
# variables | ||
######################################################################## | ||
GOPATH:=$(shell type go >/dev/null 2>&1 && go env GOPATH) | ||
export PATH:=$(if $(GOPATH),$(GOPATH)/bin:,)$(PATH) | ||
|
||
######################################################################## | ||
# targets | ||
######################################################################## | ||
|
||
.PHONY: toolchain | ||
toolchain: | ||
$(go_install) github.com/golangci/golangci-lint/cmd/[email protected] | ||
|
||
|
||
.PHONY: toolchain-update | ||
toolchain-update: go_get_flags+=-u | ||
toolchain-update: toolchain | ||
|
||
.PHONY: validate-static | ||
validate-static: | ||
golangci-lint run $(if $(filter all commands,$(VERBOSE)),-v) ./... | ||
|
||
.PHONY: test | ||
test: | ||
go test -cover -race \ | ||
-coverprofile=coverage.out -covermode=atomic \ | ||
$(if $(filter all commands,$(VERBOSE)),-v) \ | ||
$(if $(gotest_files),$(gotest_files),./...) \ | ||
$(gotest_args) \ | ||
|
||
.PHONY: validate-dynamic | ||
validate-dynamic: test | ||
|
||
.PHONY: validate | ||
validate: validate-static validate-dynamic |
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,2 @@ | ||
BUILD_OCI=false | ||
GOFLAGS=-mod=readonly |
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,40 @@ | ||
services: | ||
golang-devtools: | ||
build: | ||
context: docker-compose | ||
target: golang-devtools | ||
dockerfile: Dockerfile | ||
privileged: true | ||
security_opt: | ||
- seccomp:unconfined | ||
- apparmor:unconfined | ||
volumes: | ||
- .:/srv/workspace:z | ||
- ${DOCKER_CONFIG:-~/.docker}:/root/.docker | ||
- ${GIT_CONFIG:-~/.gitconfig}:${GIT_CONFIG_GUEST:-/root/.gitconfig} | ||
- ${SSH_CONFIG:-~/.ssh}:/root/.ssh | ||
- ${XDG_CACHE_HOME:-xdg-cache-home}:/root/.cache | ||
# ${x:-y} explained here https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#:~:text=3.5.3%20Shell%20Parameter%20Expansion | ||
environment: | ||
GOMODCACHE: /root/.cache/go-mod | ||
techdocs: | ||
build: | ||
context: docker-compose | ||
dockerfile: Dockerfile | ||
target: techdocs | ||
working_dir: /srv/workspace | ||
environment: | ||
GOOGLE_APPLICATION_CREDENTIALS: ${GOOGLE_APPLICATION_CREDENTIALS:-} | ||
GCLOUD_PROJECT: ${GCLOUD_PROJECT:-} | ||
volumes: | ||
- .:/srv/workspace:z | ||
- ${XDG_CACHE_HOME:-xdg-cache-home}:/root/.cache | ||
- $HOME/.config/gcloud:/root/.config/gcloud | ||
- ${GOOGLE_APPLICATION_CREDENTIALS:-nothing}:${GOOGLE_APPLICATION_CREDENTIALS:-/tmp/empty-GOOGLE_APPLICATION_CREDENTIALS} | ||
ports: | ||
- "127.0.0.1:3000:3000/tcp" | ||
- "127.0.0.1:8000:8000/tcp" | ||
command: serve | ||
volumes: | ||
xdg-cache-home: { } | ||
nothing: { } |
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,2 @@ | ||
FROM ghcr.io/coopnorge/engineering-docker-images/e0/devtools-golang-v1beta1:gitc-1f40b7aec2da97d51ed26c6f1d027bdee0458a0d@sha256:5abec21bdbd1fec9946a50e825692773a64e7db2ddd10d3446e1fc70cfcbca3b AS golang-devtools | ||
FROM ghcr.io/coopnorge/engineering-docker-images/e0/techdocs:gitc-520957c8b01583b35d335a49bc9d46428d3cfc5e@sha256:3c480d1f43b0dc4f46c041518c94c2c58a08406135a7250eb0d6ea70bc15b8f1 as techdocs |
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
Oops, something went wrong.