Skip to content

Commit

Permalink
Merge pull request statping-ng#222 from jemand771/dev-gha-docker
Browse files Browse the repository at this point in the history
Refactor GitHub actions + fix build
  • Loading branch information
jemand771 authored May 11, 2023
2 parents 7abc4e8 + b1edc02 commit 006476d
Show file tree
Hide file tree
Showing 17 changed files with 298 additions and 1,522 deletions.
501 changes: 0 additions & 501 deletions .github/workflows/2_unstable.yml

This file was deleted.

557 changes: 0 additions & 557 deletions .github/workflows/3_stable.yml

This file was deleted.

270 changes: 175 additions & 95 deletions .github/workflows/1_dev.yml → .github/workflows/build.yml

Large diffs are not rendered by default.

173 changes: 0 additions & 173 deletions .github/workflows/pr.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "source/statping-ng.wiki"]
path = source/statping-ng.wiki
# TODO should this be a relative path? (would require wiki fork for statping forks)
url = https://github.com/statping-ng/statping-ng.wiki.git
22 changes: 12 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN yarn build && yarn cache clean

# Statping Golang BACKEND building from source
# Creates "/go/bin/statping" and "/usr/local/bin/sass" for copying
FROM golang:1.17-alpine AS backend
FROM golang:1.20-alpine AS backend
LABEL maintainer="Statping-NG (https://github.com/statping-ng)"
ARG VERSION
ARG COMMIT
Expand All @@ -21,7 +21,7 @@ RUN apk add --update --no-cache libstdc++ gcc g++ make git autoconf \
update-ca-certificates

WORKDIR /root
RUN git clone https://github.com/sass/sassc.git
RUN git clone --depth 1 --branch 3.6.2 https://github.com/sass/sassc.git
RUN . sassc/script/bootstrap && make -C sassc -j4
# sassc binary: /root/sassc/bin/sassc

Expand All @@ -30,15 +30,17 @@ ADD go.mod go.sum ./
RUN go mod download
ENV GO111MODULE on
ENV CGO_ENABLED 1
RUN go get github.com/stretchr/testify/assert && \
go get github.com/stretchr/testify/require && \
go get github.com/GeertJohan/go.rice/rice && \
go get github.com/cortesi/modd/cmd/modd && \
go get github.com/crazy-max/xgo
COPY . .
COPY cmd ./cmd
COPY database ./database
COPY handlers ./handlers
COPY notifiers ./notifiers
COPY source ./source
COPY types ./types
COPY utils ./utils
COPY --from=frontend /statping/dist/ ./source/dist/
RUN make clean generate embed
RUN go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION} -X main.COMMIT=${COMMIT}" -o statping --tags "netgo linux" ./cmd
RUN go install github.com/GeertJohan/go.rice/rice@latest
RUN cd source && rice embed-go
RUN go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=$VERSION -X main.COMMIT=$COMMIT" -o statping --tags "netgo linux" ./cmd
RUN chmod a+x statping && mv statping /go/bin/statping
# /go/bin/statping - statping binary
# /root/sassc/bin/sassc - sass binary
Expand Down
45 changes: 0 additions & 45 deletions Dockerfile.base

This file was deleted.

4 changes: 2 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

var (
// VERSION stores the current version of Statping
VERSION string
VERSION string = "dev"
// COMMIT stores the git commit hash for this version of Statping
COMMIT string
log = utils.Log.WithField("type", "cmd")
Expand Down Expand Up @@ -83,7 +83,7 @@ func start() {
log.Errorf("Statping Log Error: %v\n", err)
}

log.Info(fmt.Sprintf("Starting Statping v%s", VERSION))
log.Info(fmt.Sprintf("Starting Statping %s", VERSION))

utils.Params.Set("SERVER_IP", ipAddress)
utils.Params.Set("SERVER_PORT", port)
Expand Down
42 changes: 42 additions & 0 deletions dev/maintainer-docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Statping-ng maintainer documentation
This document will briefly outline our workflows and give instructions on some common tasks.

Feel free to expand this; at the moment it's pretty empty here.


## GitHub actions
Binaries and docker images get built automatically by GitHub actions.
If the builds succeed, tests are run to ensure nothing is completely broken.
Build artifacts can be downloaded from the actions tab on GitHub.

This happens on every push to this repo and on every pull request update.


## Releases
We used to have a model of "stable" and "unstable" releases, which would get triggered by pushing to a respective release branch.
The new system tries to address some of the issues with the old system and simplifies the workflow definitions.

Incoming pull requests are merged into the `main` (default) branch.
Once you feel like we have enough new changes to justify a release, a tag can be created.
This is **not** a GitHub release and sadly can't be done from github.com directly.
Either
* create a stable release ready for general usage as `v{major}.{minor}.{patch}`, e.g. `v1.2.3`
* or create a beta release intended for testing as `v{major}.{minor}.{patch}-{suffix}`, e.g. `v1.2.3-rc0`
* personal note: I don't know what a good format for suffixes is. I'm not even sure if we _need_ beta releases long term. We'll see; I'm open to suggestions

To create a tag from your local workspace, run
```bash
git checkout main
git pull
git tag v1.2.3
git push origin v1.2.3
```
You can also create tags on different branches (e.g. for backports).
Remember to check out the revision you want to tag _before_ tagging.
Do not move existing (pushed) tags!

When a new tag is pushed, the same build+test actions described above run, but additionally the built docker images are pushed and a draft release on GitHub is created.
All artifacts will get attached to that release.

The release will be in draft mode to allow last minute changes if necessary.
Untick the draft checkbox if everything looks alright.
Loading

0 comments on commit 006476d

Please sign in to comment.