Skip to content

Commit

Permalink
Merge dev-1.5 in master
Browse files Browse the repository at this point in the history
  • Loading branch information
thomiceli committed Sep 26, 2023
2 parents 319a893 + 30ca090 commit 05523f6
Show file tree
Hide file tree
Showing 82 changed files with 3,209 additions and 880 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
templates/**/* linguist-vendored
public/**/*.css linguist-vendored
public/**/*.scss linguist-vendored
*.config.js linguist-vendored
72 changes: 43 additions & 29 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,63 @@
name: "Go"
name: "Go CI"
on:
push:
branches:
- master
- 'dev-*'
pull_request:

jobs:
checks:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Go 1.20
uses: actions/setup-go@v4
with:
go-version: "1.20"

- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
skip-pkg-cache: true
args: --out-format=colored-line-number --timeout=20m

- name: Format
run: make fmt check_changes

check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Go 1.20
uses: actions/setup-go@v4
with:
go-version: "1.20"

- name: Check
run: make go_mod check_changes

test:
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macOS-latest"]
go: ["1.19", "1.20"]
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
go: ["1.20", "1.21"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Go ${{ matrix.go }}
uses: WillAbides/setup-go[email protected]
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}

- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Cache Go build cache
uses: actions/cache@v3
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-build-${{ matrix.go }}
restore-keys: |
${{ runner.os }}-go-build-
- name: Run tests
run: make test

- name: Run go vet
run: "go vet ./..."

- name: Run Staticcheck
uses: dominikh/[email protected]
with:
version: "2023.1.1"
install-go: false
cache-key: ${{ matrix.go }}
29 changes: 27 additions & 2 deletions .github/workflows/docker.yml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
name: Docker
name: Release

on:
release:
types: [published]
workflow_dispatch:

jobs:
binaries-build-release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Go 1.20
uses: actions/setup-go@v4
with:
go-version: "1.20"

- name: Cross compile build
run: make all_crosscompile

- name: Upload Release Assets
uses: softprops/action-gh-release@v1
with:
files: |
build/*.tar.gz
build/*.zip
build/checksums.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docker-build-release:
runs-on: ubuntu-latest
permissions:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ gist.db
public/assets/*
public/manifest.json
opengist
build/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN apk update && \
musl-dev \
libstdc++

COPY --from=golang:1.19-alpine /usr/local/go/ /usr/local/go/
COPY --from=golang:1.20-alpine /usr/local/go/ /usr/local/go/
ENV PATH="/usr/local/go/bin:${PATH}"

COPY --from=node:18-alpine /usr/local/ /usr/local/
Expand Down
27 changes: 23 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
.PHONY: all install build_frontend build_backend build build_docker watch_frontend watch_backend watch clean clean_docker
.PHONY: all all_crosscompile install build_frontend build_backend build build_crosscompile build_docker watch_frontend watch_backend watch clean clean_docker check_changes go_mod fmt test

# Specify the name of your Go binary output
BINARY_NAME := opengist

all: install build
all: clean install build

all_crosscompile: clean install build_frontend build_crosscompile

install:
@echo "Installing NPM dependencies..."
Expand All @@ -21,6 +23,9 @@ build_backend:

build: build_frontend build_backend

build_crosscompile:
@bash ./scripts/build-all.sh

build_docker:
@echo "Building Docker image..."
docker build -t $(BINARY_NAME):latest .
Expand All @@ -34,13 +39,27 @@ watch_backend:
OG_DEV=1 npx nodemon --watch '**/*' -e html,yml,go,js --signal SIGTERM --exec 'go run . --config config.yml'

watch:
@bash ./watch.sh
@bash ./scripts/watch.sh

clean:
@echo "Cleaning up build artifacts..."
@rm -f $(BINARY_NAME) public/manifest.json
@rm -rf public/assets
@rm -rf public/assets build

clean_docker:
@echo "Cleaning up Docker image..."
@docker rmi $(BINARY_NAME)

check_changes:
@echo "Checking for changes..."
@git --no-pager diff --exit-code || (echo "There are unstaged changes detected." && exit 1)

go_mod:
@go mod download
@go mod tidy

fmt:
@go fmt ./...

test:
@go test ./... -p 1
Loading

0 comments on commit 05523f6

Please sign in to comment.