-
Notifications
You must be signed in to change notification settings - Fork 3
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
Setup env-loader CI/CD and dev tooling #284
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b090543
Setup env-loader CI/CD and dev tooling
fheinecke fef1952
Fix missing local dev tools
fheinecke 0494689
Move reusable workflows under .github/workflows
fheinecke 58a81d4
symlink reusable workflows
fheinecke d06b962
Bump linter for 1.23 compat
fheinecke c7023ae
set working dir
fheinecke e2ae333
fix building for windows arm64 instead of amd64
fheinecke f0866e4
Fix image builds
fheinecke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
|
@@ -4,50 +4,11 @@ name: Changelog generator CI | |
on: | ||
pull_request: | ||
|
||
env: | ||
TOOL_DIRECTORY: tools/changelog | ||
|
||
jobs: | ||
test: | ||
name: Run tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Determine if tests should run | ||
# This is a monorepo and GH checks cannot be required for only specific | ||
# paths, so this is required instead of a trigger `paths` filter. | ||
- name: Check if relavent files have changed | ||
id: changes | ||
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 | ||
with: | ||
filters: | | ||
tool: | ||
- 'tools/changelog/**' | ||
- '.github/workflows/changelog-ci.yaml' | ||
|
||
# Setup | ||
- name: Checkout repository | ||
if: steps.changes.outputs.tool == 'true' | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
- name: Setup Go | ||
if: steps.changes.outputs.tool == 'true' | ||
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 | ||
with: | ||
go-version-file: "${{ env.TOOL_DIRECTORY }}/go.mod" | ||
|
||
# Linting | ||
- name: Install golangci-lint | ||
if: steps.changes.outputs.tool == 'true' | ||
run: go install github.com/golangci/golangci-lint/cmd/[email protected] | ||
- name: Lint | ||
if: steps.changes.outputs.tool == 'true' | ||
working-directory: ${{ env.TOOL_DIRECTORY }} | ||
run: make lint | ||
|
||
# Tests | ||
- name: Install gotestsum | ||
if: steps.changes.outputs.tool == 'true' | ||
run: go install gotest.tools/[email protected] | ||
- name: Run tests | ||
if: steps.changes.outputs.tool == 'true' | ||
working-directory: ${{ env.TOOL_DIRECTORY }} | ||
run: make test | ||
release: | ||
uses: ./tools/repo-release-tooling/workflows/reusable-ci.yaml | ||
permissions: | ||
contents: write | ||
packages: write | ||
with: | ||
tool-directory: ./tools/changelog |
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,25 @@ | ||
--- | ||
name: Environment value loader CD | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- tools/env-loader | ||
tags: | ||
- "tools/env-loader/v[0-9]+.[0-9]+.[0-9]+**" | ||
pull_request: | ||
paths: | ||
- tools/env-loader/workflows/cd.yaml | ||
- .github/workflows/env-loader-cd.yaml | ||
- tools/repo-release-tooling/workflows/reusable-cd.yaml | ||
|
||
jobs: | ||
release: | ||
uses: ./tools/repo-release-tooling/workflows/reusable-cd.yaml | ||
permissions: | ||
contents: write | ||
packages: write | ||
with: | ||
tool-directory: ./tools/env-loader |
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,14 @@ | ||
--- | ||
name: Environment value loader CI | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
release: | ||
uses: ./tools/repo-release-tooling/workflows/reusable-ci.yaml | ||
permissions: | ||
contents: write | ||
packages: write | ||
with: | ||
tool-directory: ./tools/env-loader |
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 |
---|---|---|
@@ -1,34 +1,3 @@ | ||
OS ?= $(shell uname -s | tr '[[:upper:]]' '[[:lower:]]') | ||
ARCH ?= $(shell uname -m) | ||
TOOL_NAME = changelog | ||
BUILD_DIR = build/$(OS)/$(ARCH) | ||
VERSION = v0.0.0-dev | ||
BINARY_NAME = $(TOOL_NAME) | ||
ifeq ($(OS),windows) | ||
BINARY_NAME := $(BINARY_NAME).exe | ||
endif | ||
|
||
lint: | ||
@golangci-lint run ./... --out-format colored-line-number | ||
|
||
test: | ||
@gotestsum --format github-actions ./... -- -shuffle on -timeout 2m -race | ||
|
||
binary: | ||
@echo "Building for $(OS)/$(ARCH) and writing to $(BUILD_DIR)" | ||
@mkdir -p "$(BUILD_DIR)" | ||
@GOOS=$(OS) GOARCH=$(ARCH) go build -o "$(BUILD_DIR)/" -ldflags="-s -w" | ||
|
||
tarball: TARBALL_NAME = $(TOOL_NAME)-$(VERSION)-$(OS)-$(ARCH).tar.gz | ||
tarball: binary | ||
tar -C "$(BUILD_DIR)" -czvf "$(BUILD_DIR)/$(TARBALL_NAME)" "$(BINARY_NAME)" > /dev/null | ||
|
||
container-image: OS = linux | ||
container-image: binary | ||
@docker buildx build --platform="linux/$(ARCH)" -t "$(TOOL_NAME)" . | ||
|
||
clean: | ||
@rm -rf build/ | ||
@docker image rm -f "$(TOOL_NAME):$(VERSION)" 2> /dev/null | ||
|
||
.PHONY: lint test binary tarball container-image clean | ||
include ../repo-release-tooling/tooling.mk |
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,6 @@ | ||
FROM mcr.microsoft.com/vscode/devcontainers/go | ||
|
||
RUN apt update && \ | ||
apt install -y --no-install-recommends age | ||
|
||
COPY --from=ghcr.io/getsops/sops:v3.9.1 /usr/local/bin/sops /usr/local/bin/sops |
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,21 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. | ||
{ | ||
"name": "env-loader", | ||
"build": { | ||
"dockerfile": "Dockerfile" | ||
}, | ||
"features": { | ||
"ghcr.io/devcontainers/features/github-cli:1": {} | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"github.vscode-github-actions", | ||
"redhat.vscode-yaml" | ||
] | ||
} | ||
}, | ||
"mounts": [ | ||
"type=bind,source=${localEnv:HOME}/.config/gh,target=/home/vscode/.config/gh,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 @@ | ||
build/* |
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,4 @@ | ||
TOOL_NAME = env-loader | ||
PACKAGE_PATH = ./cmd/env-loader.go | ||
|
||
include ../repo-release-tooling/tooling.mk |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand release workflows being separate but for CI can we simplify and just have one workflow that executes all tests? Right now tools may be nicely separated but what if they say use a shared library and it gets modified, this sort of separation will just add headache later. Let's just have a single "unit tests" workflow that runs all Go tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify what kind of issue this will cause? A large portion of this RFD and the structure it introduced was to reduce headaches and problems introduced by coupling projects together.