Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: Heathcliff <[email protected]>
  • Loading branch information
heathcliff26 committed Apr 2, 2024
0 parents commit fcf3aa7
Show file tree
Hide file tree
Showing 199 changed files with 311,311 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_size = 4

[*.{yaml,yml}]
indent_style = space
indent_size = 2

[*.{json,json5}]
indent_style = space
indent_size = 2

[*.sh]
indent_style = space
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Default owner
* @heathcliff26
5 changes: 5 additions & 0 deletions .github/renovate-bot.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"username": "bot-ahsoka[bot]",
"gitAuthor": "bot-ahsoka[bot] <bot-ahsoka[bot]@users.noreply.github.com>",
}
21 changes: 21 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended",
"docker:enableMajor",
":disableRateLimiting",
":dependencyDashboard",
":semanticCommits",
":automergeDigest",
"github>heathcliff26/ci//renovate/commitMessage.json5",
"github>heathcliff26/ci//renovate/customManagers.json5",
"github>heathcliff26/ci//renovate/group-gomod.json5",
"github>heathcliff26/ci//renovate/labels.json5",
"github>heathcliff26/ci//renovate/semanticCommits.json5",
"helpers:pinGitHubActionDigests"
],
"assigneesFromCodeOwners": true,
"dependencyDashboardTitle": "Renovate Dashboard 🤖",
"suppressNotifications": ["prIgnoreNotification"],
"postUpdateOptions": ["gomodTidy"],
}
40 changes: 40 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: CI

on:
workflow_dispatch:
inputs:
tag:
description: "Use to set tag, default: rolling"
type: string
default: "rolling"
required: false
push:
branches: ["main"]
paths:
- "go.mod"
- "go.sum"
- "*.go"
- "**/*.go"
- "Dockerfile"
pull_request:
branches: ["main"]
merge_group:
branches: ["main"]

jobs:
lint:
uses: heathcliff26/ci/.github/workflows/golang-lint.yaml@main

build:
uses: heathcliff26/ci/.github/workflows/build-container.yaml@main
needs:
- lint
permissions:
contents: read
packages: write
with:
dockerfile: Dockerfile
tag: "${{ github.event.inputs.tag }}"
dry-run: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
secrets: inherit
15 changes: 15 additions & 0 deletions .github/workflows/editorconfig-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: "Editorconfig Check"

on:
workflow_dispatch:
push:
branches: ["main", "renovate/*"]
pull_request:
branches: ["main"]
merge_group:
branches: ["main"]

jobs:
check-editorconfig:
uses: heathcliff26/ci/.github/workflows/editorconfig-check.yaml@main
15 changes: 15 additions & 0 deletions .github/workflows/go-testcover-report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: "Generate go test cover report"

on:
workflow_dispatch:
push:
branches: ["main"]
paths:
- "*.go"
- "**/*.go"

jobs:
generate-reports:
uses: heathcliff26/ci/.github/workflows/golang-testcover-report.yaml@main
secrets: inherit
18 changes: 18 additions & 0 deletions .github/workflows/label-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: "Labels Check"

on:
pull_request:
branches: ["main"]
types:
- opened
- synchronize
- reopened
- labeled
- unlabeled

jobs:
check-labels:
permissions:
pull-requests: read
uses: heathcliff26/ci/.github/workflows/label-check.yaml@main
14 changes: 14 additions & 0 deletions .github/workflows/link-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: "Link Check"

on:
workflow_dispatch:
schedule:
- cron: "0 0 * * 0"

jobs:
check-links:
uses: heathcliff26/ci/.github/workflows/link-check.yaml@main
secrets: inherit
with:
exclude-paths: "vendor"
22 changes: 22 additions & 0 deletions .github/workflows/renovate-config-validator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: "Validate Renovate Config"

on:
workflow_dispatch:
push:
branches: ["main"]
paths:
- .github/renovate-bot.json5
- .github/renovate.json5
pull_request:
branches: ["main"]
paths:
- .github/renovate-bot.json5
- .github/renovate.json5
- .github/workflows/renovate-config-validator.yaml
merge_group:
branches: ["main"]

jobs:
validate-renovate-config:
uses: heathcliff26/ci/.github/workflows/renovate-config-validator.yaml@main
46 changes: 46 additions & 0 deletions .github/workflows/renovate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: "Renovate"

on:
workflow_dispatch:
inputs:
dry-run:
description: "dry-run"
default: "false"
required: false
log-level:
description: "log-level"
default: debug
required: false
schedule:
- cron: "10 * * * 5"
push:
branches: ["main"]
paths:
- .github/renovate-bot.json5
- .github/renovate.json5

env:
LOG_LEVEL: debug
RENOVATE_DRY_RUN: false

jobs:
prepare:
runs-on: ubuntu-latest
outputs:
dry-run: ${{ steps.config.outputs.dry-run }}
log-level: "${{ steps.config.outputs.log-level }}"
steps:
- name: Generate config from dispatch variables or defaults
id: config
run: |
echo "dry-run=${{ github.event.inputs.dry-run || env.RENOVATE_DRY_RUN }}" >> "$GITHUB_OUTPUT"
echo "log-level=${{ github.event.inputs.log-level || env.LOG_LEVEL }}" >> "$GITHUB_OUTPUT"
renovate:
needs: prepare
uses: heathcliff26/ci/.github/workflows/renovate.yaml@main
with:
dry-run: ${{ needs.prepare.outputs.dry-run }}
log-level: "${{ needs.prepare.outputs.log-level }}"
secrets: inherit
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Ignore binaries
/bin

# Generated go-test coverage reports
coverprofiles/

# Ignore files created for testing
test-config.yaml
test.db
11 changes: 11 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
run:
timeout: 1m
tests: true
skip-dirs-use-default: true
modules-download-mode: readonly
output:
format: colored-line-number
print-issued-lines: true
print-linter-name: true
unique-by-line: true
10 changes: 10 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"EditorConfig.EditorConfig",
"GitHub.vscode-github-actions",
"mrmlnc.vscode-json5",
"redhat.vscode-yaml"
]
}
54 changes: 54 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
###############################################################################
# BEGIN build-stage
# Compile the binary
FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.22.1@sha256:0b55ab82ac2a54a6f8f85ec8b943b9e470c39e32c109b766bbc1b801f3fa8d3b AS build-stage

ARG BUILDPLATFORM
ARG TARGETARCH

WORKDIR /app

COPY vendor ./vendor
COPY go.mod go.sum ./
COPY cmd ./cmd
COPY pkg ./pkg

RUN CGO_ENABLED=1 GOOS=linux GOARCH="${TARGETARCH}" go build -ldflags="-w -s" -o /fleetlock ./cmd/

#
# END build-stage
###############################################################################

###############################################################################
# BEGIN test-stage
# Run the tests in the container
FROM docker.io/library/golang:1.22.1@sha256:0b55ab82ac2a54a6f8f85ec8b943b9e470c39e32c109b766bbc1b801f3fa8d3b AS test-stage

WORKDIR /app

COPY --from=build-stage /app /app
# Not needed for testing, but needed for later stage
COPY --from=build-stage /fleetlock /

RUN go test -v ./...

#
# END test-stage
###############################################################################

###############################################################################
# BEGIN final-stage
# Create final docker image
FROM scratch AS final-stage

WORKDIR /

COPY --from=test-stage /fleetlock /

USER 1001

ENTRYPOINT ["/fleetlock"]

#
# END final-stage
###############################################################################
Loading

0 comments on commit fcf3aa7

Please sign in to comment.