Skip to content

V0.2.0 review updates #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 41 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
e912938
fix(Dockerfile): readability and golang image update
Jul 7, 2022
f126524
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 7, 2022
6daad1b
fix(Dockerfile): addressing comments and adding dependabot for docker
mridulganga Jul 8, 2022
c114f71
refactor(semantic-release): Update the name of job to represent tag a…
Jul 9, 2022
41fab29
refactor(semantic-release): Update formatting
Jul 9, 2022
1ed3a99
refactor(sonarcloud): Add step names, follow lowercase workflow name …
Jul 9, 2022
f0ccb7a
refactor(go-test): Follow lowercase file/workflow name convention and…
Jul 9, 2022
9b69a3f
refactor(gitleaks): Follow lowercase file/workflow name convention an…
Jul 9, 2022
22e6db4
refactor(mkdocs): Update workflow name to represent the tooling as pe…
Jul 9, 2022
db0c706
refactor(mkdocs): Add step names
Jul 9, 2022
9e236d9
refactor(golangci-lint): Update step name to action taken
Jul 9, 2022
2820507
refactor(golangci-lint): Add step names
Jul 9, 2022
1f1c803
docs(pre-commit): Fix info about how pre-commit is run in github
Jul 9, 2022
57d0e9e
docs(readme): Starter instructions
Jul 10, 2022
1c14723
docs(sonarcloud): Fix name
Jul 10, 2022
f1d45f6
refactor(gitleaks,golangci-lint,go-test): Avoid duplicate builds when…
Jul 10, 2022
2c97eaa
docs(readme): Add sample template
Jul 10, 2022
8f90975
build(gitignore): Ignore mac .DS_Store
Jul 10, 2022
df66bdf
docs(mkdocs): Update workflow name
Jul 10, 2022
52ad3bc
refactor(sonarcloud): Follow lowercase naming convention
haani-niyaz Jul 10, 2022
e3287b4
Addressing comments
mridulganga Jul 11, 2022
6cf4cdc
docs(pre-commit): Add pre-commit ci auto fix pull requests description
Jul 11, 2022
4233cf5
docs(semantic-release): Improve ci workflow description
Jul 11, 2022
3ef52b1
docs(mkdocs): Improve ci workflow description
Jul 11, 2022
05ccb01
docs(goreleaser): Add user docs
Jul 11, 2022
38560e9
Merge branch 'main' into dockerfile-fix
shukra-in-spirit Jul 12, 2022
d282e78
Merge branch 'main' into v0.2.0-review-updates
shukra-in-spirit Jul 12, 2022
7de7481
add common license details
shukra-in-spirit Jul 12, 2022
26a83f6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 12, 2022
cc9230e
Merge branch 'main' into v0.2.0-review-updates
pallasite99 Jul 13, 2022
19aba38
docs(readme): Draw attention to review the Quickstart doc as it has c…
Jul 14, 2022
1fc955d
Merge branch 'v0.2.0-review-updates' of https://github.com/rog-golang…
Jul 14, 2022
5e87c80
Merge branch 'main' into dockerfile-fix
Jul 18, 2022
452aa49
refactor(Dockerfile): Remove redundant comment
Jul 26, 2022
84afbb1
refactor(Dockerfile): Fix comment
Jul 26, 2022
5b3977d
Merge branch 'main' into v0.2.0-review-updates
haani-niyaz Jul 26, 2022
ed33a5b
Merge branch 'v0.2.0-review-updates' into dockerfile-fix
haani-niyaz Jul 26, 2022
4d9a96a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 26, 2022
a28f2ef
Merge pull request #45 from rog-golang-buddies/dockerfile-fix
haani-niyaz Jul 26, 2022
b5c9dea
fix(sonarcloud): Descope since the same project is being used by all …
Jul 26, 2022
34330ec
feat(placeholder): Initiate v0.2.0 release
Jul 26, 2022
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
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ updates:
schedule:
interval: weekly
open-pull-requests-limit: 5
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
20 changes: 0 additions & 20 deletions .github/workflows/SonarCloud.yml

This file was deleted.

14 changes: 5 additions & 9 deletions .github/workflows/gitleaks.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
name: Gitleaks

on: [pull_request, push, workflow_dispatch]

name: gitleaks
on: [push]
jobs:
gitleaks:
name: Secret Scan
runs-on: ubuntu-latest
steps:
- name: Check out the repo
- name: Checkout
uses: actions/checkout@v2
- name: Run gitleaks
run: docker run -v ${{ github.workspace }}:/path zricethezav/gitleaks:latest detect -v --source="/path" --redact

run-if-failed:
name: Github Security Report (if gitleaks job fails)
name: gen-report (if gitleaks fails)
runs-on: ubuntu-latest
needs: [gitleaks]
if: always() && (needs.gitleaks.result == 'failure')
permissions:
security-events: write
steps:
- name: Check out the repo
- name: Checkout
uses: actions/checkout@v2
- name: Generate gitleaks SARIF file
# Exit 0 so we can get the failed report results from this step.
Expand Down
18 changes: 0 additions & 18 deletions .github/workflows/go-test.yml

This file was deleted.

12 changes: 5 additions & 7 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
name: golangci-lint
on:
push:
pull_request:
on: [push]
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
golangci:
name: lint
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.17
- uses: actions/checkout@v3
- name: golangci-lint
- name: Checkout
uses: actions/checkout@v3
- name: Run linters
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
name: gen-docs
name: mkdocs
on:
push:
branches:
- master
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- run: pip install mkdocs-material
- run: mkdocs gh-deploy --force
- name: Install mkdocs-material
run: pip install mkdocs-material
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should consider using a golang alternative for mkdocs as its sad a golang template repo needs python 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make a fresh issue for this @mridulganga, we went for anything that we were able to get working.

Now, would be a good time to start working on evaluating and taking out non-golang bits.

- name: Publish to gh-pages
run: mkdocs gh-deploy --force
11 changes: 6 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
name: release

on:
push:
branches:
- main
jobs:
tag:
semantic-release:
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 16.x
steps:
- name: Checkout
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Release
-
name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
goreleaser:
runs-on: ubuntu-latest
needs: tag
needs: semantic-release
steps:
-
name: Checkout
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: tests
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Go Test
run: go test -v ./...
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.dll
*.so
*.dylib
bin/

# Test binary, built with `go test -c`
*.test
Expand All @@ -14,4 +15,9 @@
# Dependency directories (remove the comment below to include it)
# vendor/

bin/
# Code editor personal settings
.vscode/
.idea/

# Other
.DS_Store
23 changes: 16 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
FROM golang:1.18 as build
WORKDIR /go/src/app
FROM golang:1.18-alpine as builder

RUN apk update && apk upgrade && \
apk add --no-cache make bash

WORKDIR /src
COPY . .
# Static build requires CGO_ENABLED=0
RUN mkdir -p /go/bin && CGO_ENABLED=0 go build -ldflags="-w -s" -o /go/bin/app ./...

# Build executable
RUN make build

# Using a distroless image from https://github.com/GoogleContainerTools/distroless
# Image sourced from https://console.cloud.google.com/gcr/images/distroless/global/static
FROM gcr.io/distroless/static:nonroot
COPY --from=build /go/bin/app /
# numeric version of user nonroot:nonroot provided in image

# Copy executable from builder image
COPY --from=builder /src/bin/app /

# Numeric version of user nonroot:nonroot provided in image
USER 65532:65532

# Run the executable
CMD ["/app"]
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
SHELL=/bin/bash -e -o pipefail
PWD = $(shell pwd)
GO_BUILD= go build
GOFLAGS= CGO_ENABLED=0

## help: Print this help message
.PHONY: help
Expand Down Expand Up @@ -37,4 +39,4 @@ fmt:
## build: Build binary into bin/ directory
.PHONY: build
build:
go build -ldflags="-w -s" -o bin/app ./...
$(GOFLAGS) $(GO_BUILD) -a -v -ldflags="-w -s" -o bin/app cmd/main.go
72 changes: 62 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,67 @@
# golang-template-repository
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/rog-golang-buddies/golang-template-repository/main.svg)](https://results.pre-commit.ci/latest/github/rog-golang-buddies/golang-template-repository/main)

Kickstarter repository for a golang service
> 💣   _All Setup content in this file should be replaced with your project details post setup._

Dockerhub: docker push golangbuddy/test-project:tagname
## Setup

TODO:
A gh-pages site is automatically generated for you when you clone/fork this repository. To get started, you must configure gh-pages with a few easy clicks for the site to be published. You can then follow the pre-written site docs to familiarize yourself with this repository.

1. ~~Add a CI skeleton.~~
2. ~~Add basic linting.~~
3. ~~Add secret-scanning.~~
4. Add makefile.
5. Add containerization.
### Steps

🎛️   Configure gh-pages as per instructions [here](https://rog-golang-buddies.github.io/golang-template-repository/continuous-integration/mkdocs-material/#ci-setup).

🌐 &nbsp; Goto your site at `<org>.github.io/<repository>` (the link is also made available via **Environments** section in your Github repo).

✋ &nbsp; Take a moment to review the `Quickstart` guide before you get started. It has critical prerequisites.

🧐 &nbsp; Peruse the `Continuous integration` docs to get yourself upto speed.

> _Having trouble accessing your site? Access the template repository Quickstart and Continuous integration docs here_: <br>
https://rog-golang-buddies.github.io/golang-template-repository

🚀 &nbsp; Go build something amazing!

---
<br>

> _The following section provides a sample README template sourced from https://www.makeareadme.com_

# [Repo name]

## Description

_Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors._


## Installation

_Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection._

## Usage

_Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README._

## Support

_Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc._

## Roadmap

_If you have ideas for releases in the future, it is a good idea to list them in the README._

## Contributing

_State if you are open to contributions and what your requirements are for accepting them._

_For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self._

_You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser._

## Authors and acknowledgment

_Show your appreciation to those who have contributed to the project._

## License

_For open source projects, say how it is licensed._
_Commonly used open-source licenses are MIT (https://opensource.org/licenses/MIT) and Apache (https://www.apache.org/licenses/LICENSE-2.0).
Binary file removed docs/.DS_Store
Binary file not shown.
31 changes: 31 additions & 0 deletions docs/continuous-integration/goreleaser.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# GoReleaser

## What

[GoReleaser](https://goreleaser.com/) builds Go binaries for several platforms. The goal is to simplify the build, release and publish steps while providing variant customization options for all steps.

## Why

Simplifies the build and packing process of your app's Go binaries.

## How

The entire release process can be customized through a `.goreleaser.yml` file. Once you set it up, every time you want to create a new release, all you need to do is create a git tag that conforms to [semantic versioning](https://goreleaser.com/limitations/semver/) and run `goreleaser release`.


## CI setup

!!! summary

No configuration required.

GoReleaser is configured to run on the `main` branch and is executed via the release Github workflow in `.github/workflows/release.yml`.


!!! info

Binaries are only created if a tag exists. This is controlled via [semantic-release](semantic-release.md).

## Local setup

The [quickstart](https://goreleaser.com/quick-start/) provides detailed steps to run GoReleaser locally.
2 changes: 1 addition & 1 deletion docs/continuous-integration/mkdocs-material.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The repository is preconfigured with a `./docs` directory and renders all markdo

### Github pages

A gen-docs workflow is configured to automatically run on the `main` branch however it requires github-pages to be enabled in the repository settings.
`mkdocs` is configured to automatically run on the `main` branch and is executed via the mkdocs Github workflow in `.github/workflows/mkdocs.yml`. However, it requires github-pages to be enabled in the repository settings.

See the screenshot below:

Expand Down
12 changes: 11 additions & 1 deletion docs/continuous-integration/pre-commit.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,17 @@ Any detected failures will abort the commit.

No configuration required.

All hooks in `.pre-commit-config.yaml` will be executed via the pre-commit Github workflow in `.github/workflows/pre-commit.yml`.
All hooks in `.pre-commit-config.yaml` will be executed via the automatic integration provided from [pre-commit ci](https://pre-commit.ci/).

`pre-commit ci` runs automatically on pull request commits.

### Auto fixing pull requests

If tools (configured in `.pre-commit-config.yaml`) make changes to files during a pull request, pre-commit.ci will automatically fix the pull request.

pre-commit.ci will run on all pull request commits, but will not push for commits made by bots.

The impact of this means developers will need to fetch the latest changes if further work must be done on the PR branch.

## Local setup

Expand Down
Loading