1
0
mirror of https://github.com/siderolabs/kres.git synced 2026-02-05 09:45:35 +01:00

feat: github action workflow support

Support creating GitHub actions workflow.

Signed-off-by: Noel Georgi <git@frezbo.dev>
This commit is contained in:
Noel Georgi
2023-08-31 23:25:59 +05:30
parent 328234bbad
commit 85409470da
50 changed files with 896 additions and 404 deletions

View File

@@ -1,359 +0,0 @@
---
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2023-08-31T15:39:43Z by kres d3c3205-dirty.
kind: pipeline
type: kubernetes
name: default
platform:
os: linux
arch: amd64
steps:
- name: setup-ci
pull: always
image: autonomy/build-container:latest
commands:
- sleep 5
- git fetch --tags
- install-ci-key
- docker buildx create --driver docker-container --platform linux/amd64 --name local --use unix:///var/outer-run/docker.sock
- docker buildx inspect --bootstrap
environment:
SSH_KEY:
from_secret: ssh_key
volumes:
- name: outer-docker-socket
path: /var/outer-run
- name: docker-socket
path: /var/run
- name: buildx
path: /root/.docker/buildx
- name: ssh
path: /root/.ssh
- name: base
pull: always
image: autonomy/build-container:latest
commands:
- make base
volumes:
- name: outer-docker-socket
path: /var/outer-run
- name: docker-socket
path: /var/run
- name: buildx
path: /root/.docker/buildx
- name: ssh
path: /root/.ssh
depends_on:
- setup-ci
- name: unit-tests
pull: always
image: autonomy/build-container:latest
commands:
- make unit-tests
volumes:
- name: outer-docker-socket
path: /var/outer-run
- name: docker-socket
path: /var/run
- name: buildx
path: /root/.docker/buildx
- name: ssh
path: /root/.ssh
depends_on:
- base
- name: unit-tests-race
pull: always
image: autonomy/build-container:latest
commands:
- make unit-tests-race
volumes:
- name: outer-docker-socket
path: /var/outer-run
- name: docker-socket
path: /var/run
- name: buildx
path: /root/.docker/buildx
- name: ssh
path: /root/.ssh
depends_on:
- base
- name: coverage
pull: always
image: autonomy/build-container:latest
commands:
- make coverage
environment:
CODECOV_TOKEN:
from_secret: CODECOV_TOKEN
volumes:
- name: outer-docker-socket
path: /var/outer-run
- name: docker-socket
path: /var/run
- name: buildx
path: /root/.docker/buildx
- name: ssh
path: /root/.ssh
depends_on:
- unit-tests
- name: kres
pull: always
image: autonomy/build-container:latest
commands:
- make kres
volumes:
- name: outer-docker-socket
path: /var/outer-run
- name: docker-socket
path: /var/run
- name: buildx
path: /root/.docker/buildx
- name: ssh
path: /root/.ssh
depends_on:
- base
- name: lint
pull: always
image: autonomy/build-container:latest
commands:
- make lint
volumes:
- name: outer-docker-socket
path: /var/outer-run
- name: docker-socket
path: /var/run
- name: buildx
path: /root/.docker/buildx
- name: ssh
path: /root/.ssh
depends_on:
- base
- name: image-kres
pull: always
image: autonomy/build-container:latest
commands:
- make image-kres
volumes:
- name: outer-docker-socket
path: /var/outer-run
- name: docker-socket
path: /var/run
- name: buildx
path: /root/.docker/buildx
- name: ssh
path: /root/.ssh
depends_on:
- kres
- lint
- unit-tests
- name: push-kres
pull: always
image: autonomy/build-container:latest
commands:
- docker login ghcr.io --username "$${GHCR_USERNAME}" --password "$${GHCR_PASSWORD}"
- make image-kres
environment:
GHCR_PASSWORD:
from_secret: ghcr_token
GHCR_USERNAME:
from_secret: ghcr_username
PUSH: true
volumes:
- name: outer-docker-socket
path: /var/outer-run
- name: docker-socket
path: /var/run
- name: buildx
path: /root/.docker/buildx
- name: ssh
path: /root/.ssh
when:
event:
exclude:
- pull_request
depends_on:
- image-kres
- name: push-kres-latest
pull: always
image: autonomy/build-container:latest
commands:
- docker login ghcr.io --username "$${GHCR_USERNAME}" --password "$${GHCR_PASSWORD}"
- make image-kres TAG=latest
environment:
GHCR_PASSWORD:
from_secret: ghcr_token
GHCR_USERNAME:
from_secret: ghcr_username
PUSH: true
volumes:
- name: outer-docker-socket
path: /var/outer-run
- name: docker-socket
path: /var/run
- name: buildx
path: /root/.docker/buildx
- name: ssh
path: /root/.ssh
when:
branch:
- main
event:
exclude:
- pull_request
depends_on:
- push-kres
- name: release-notes
pull: always
image: autonomy/build-container:latest
commands:
- make release-notes
volumes:
- name: outer-docker-socket
path: /var/outer-run
- name: docker-socket
path: /var/run
- name: buildx
path: /root/.docker/buildx
- name: ssh
path: /root/.ssh
when:
event:
- tag
depends_on:
- unit-tests
- coverage
- kres
- image-kres
- lint
- name: release
pull: always
image: plugins/github-release
settings:
api_key:
from_secret: github_token
checksum:
- sha256
- sha512
draft: true
files:
- _out/*
note: _out/RELEASE_NOTES.md
volumes:
- name: outer-docker-socket
path: /var/outer-run
- name: docker-socket
path: /var/run
- name: buildx
path: /root/.docker/buildx
- name: ssh
path: /root/.ssh
when:
event:
- tag
depends_on:
- release-notes
services:
- name: docker
image: docker:24.0-dind
entrypoint:
- dockerd
commands:
- --dns=8.8.8.8
- --dns=8.8.4.4
- --mtu=1500
- --log-level=error
privileged: true
volumes:
- name: dev
path: /dev
- name: outer-docker-socket
path: /var/outer-run
- name: docker-socket
path: /var/run
- name: buildx
path: /root/.docker/buildx
- name: ssh
path: /root/.ssh
volumes:
- name: outer-docker-socket
host:
path: /var/ci-docker
- name: docker-socket
temp:
medium: memory
- name: buildx
temp:
medium: memory
- name: ssh
temp:
medium: memory
- name: dev
host:
path: /dev
trigger:
branch:
exclude:
- renovate/*
- dependabot/*
event:
exclude:
- promote
- cron
---
kind: pipeline
type: kubernetes
name: notify
platform:
os: linux
arch: amd64
clone:
disable: true
steps:
- name: slack
image: plugins/slack
settings:
channel: proj-talos-maintainers
link_names: true
template: "{{#if build.pull }}\n*{{#success build.status}}✓ Success{{else}}✕ Fail{{/success}}*: {{ repo.owner }}/{{ repo.name }} - <https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ build.pull }}|Pull Request #{{ build.pull }}>\n{{else}}\n*{{#success build.status}}✓ Success{{else}}✕ Fail{{/success}}: {{ repo.owner }}/{{ repo.name }} - Build #{{ build.number }}* (type: `{{ build.event }}`)\n{{/if}}\nCommit: <https://github.com/{{ repo.owner }}/{{ repo.name }}/commit/{{ build.commit }}|{{ truncate build.commit 8 }}>\nBranch: <https://github.com/{{ repo.owner }}/{{ repo.name }}/commits/{{ build.branch }}|{{ build.branch }}>\nAuthor: {{ build.author }}\n<{{ build.link }}|Visit build page>"
webhook:
from_secret: slack_webhook
when:
status:
- success
- failure
trigger:
branch:
exclude:
- renovate/*
- dependabot/*
status:
- success
- failure
depends_on:
- default
...

16
.github/renovate.json vendored
View File

@@ -19,6 +19,22 @@
}
],
"packageRules": [
{
"matchPackageNames": [
"golang/go"
],
"versioning": "regex:^(?<major>\\d+)\\.(?<minor>\\d+)\\.?(?<patch>\\d+)?$"
},
{
"matchPackageNames": [
"actions/checkout",
"docker/login-action",
"crazy-max/ghaction-github-release",
"docker/setup-buildx-action",
"slackapi/slack-github-action"
],
"versioning": "regex:^v(?<major>\\d+)"
},
{
"matchPackagePatterns": [
"*"

View File

@@ -5,15 +5,95 @@ name: default
- main
tags:
- v*
pull_request:
pull_request: {}
env:
CI_ARGS: --cache-from=type=registry,ref=registry.ci.svc.cluster.local:5000/${GITHUB_REPOSITORY}:buildcache --cache-to=type=registry,ref=registry.ci.svc.cluster.local:5000/${GITHUB_REPOSITORY}:buildcache,mode=max
CI_ARGS: --cache-from=type=registry,ref=registry.dev.siderolabs.io/${GITHUB_REPOSITORY}:buildcache --cache-to=type=registry,ref=registry.dev.siderolabs.io/${GITHUB_REPOSITORY}:buildcache,mode=max
jobs:
default:
permissions:
contents: write
packages: write
runs-on: self-hosted
runs-on:
- self-hosted
- X64
steps:
- name: checkout
uses: actions/checkout@v3
- name: Unshallow
run: |
git fetch --prune --unshallow
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
config-inline: |
[worker.oci]
gc = true
gckeepstorage = 100000 # 100 GiB
[[worker.oci.gcpolicy]]
keepBytes = 32212254720 # 30 GiB
keepDuration = 604800
filters = [ "type==source.local", "type==exec.cachemount", "type==source.git.checkout"]
[[worker.oci.gcpolicy]]
all = true
keepBytes = 107374182400 # 100 GiB
- name: base
run: |
make base
- name: unit-tests
run: |
make unit-tests
- name: unit-tests-race
run: |
make unit-tests-race
- name: coverage
run: |
make coverage
- name: kres
run: |
make kres
- name: lint
run: |
make lint
- name: Login to registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
username: ${{ github.repository_owner }}
- name: image-kres
run: |
make image-kres
- name: push-kres
if: github.event_name != 'pull_request'
env:
PLATFORM: linux/amd64,linux/arm64
PUSH: "true"
run: |
make image-kres
- name: push-kres-latest
if: github.event_name != 'pull_request'
env:
PLATFORM: linux/amd64,linux/arm64
PUSH: "true"
run: |
make image-kres TAG=latest
- name: Generate Checksums
if: startsWith(github.ref, 'refs/tags/')
run: |
sha256sum _out/kres-* > _out/sha256sum.txt
sha512sum _out/kres-* > _out/sha512sum.txt
- name: release-notes
if: startsWith(github.ref, 'refs/tags/')
run: |
make release-notes
- name: Release
if: startsWith(github.ref, 'refs/tags/')
uses: crazy-max/ghaction-github-release@v1
with:
body_path: _out/RELEASE_NOTES.md
draft: "true"
files: |-
_out/kres-*
_out/sha*.txt

View File

@@ -11,13 +11,29 @@
#
#
# Any node in the tree might have its configuration overridden via the config.
---
kind: common.Image
name: image-kres
spec:
extraEnvironment:
PLATFORM: linux/amd64,linux/arm64
entrypointArgs: ['gen']
---
kind: golang.Build
spec:
outputs:
linux-amd64:
GOOS: linux
GOARCH: amd64
linux-arm64:
GOOS: linux
GOARCH: arm64
darwin-amd64:
GOOS: darwin
GOARCH: amd64
darwin-arm64:
GOOS: darwin
GOARCH: arm64
---
kind: service.CodeCov
spec:
@@ -31,3 +47,9 @@ spec:
kind: golang.Generate
spec:
versionPackagePath: internal/version
---
kind: common.Release
name: release
spec:
artifacts:
- kres-*

View File

@@ -2,13 +2,13 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2023-08-21T12:13:35Z by kres b3de460.
# Generated on 2023-09-05T19:02:56Z by kres 0d3003d-dirty.
ARG TOOLCHAIN
FROM ghcr.io/siderolabs/ca-certificates:v1.5.0 AS image-ca-certificates
FROM ghcr.io/siderolabs/ca-certificates:v1.6.0-alpha.0-10-gd3d7d29 AS image-ca-certificates
FROM ghcr.io/siderolabs/fhs:v1.5.0 AS image-fhs
FROM ghcr.io/siderolabs/fhs:v1.6.0-alpha.0-10-gd3d7d29 AS image-fhs
# runs markdownlint
FROM docker.io/node:20.5.1-alpine3.18 AS lint-markdown
@@ -113,6 +113,30 @@ COPY --from=unit-tests-run /src/coverage.txt /coverage-unit-tests.txt
FROM scratch AS generate
COPY --from=embed-abbrev-generate /src/internal/version internal/version
# builds kres-darwin-amd64
FROM base AS kres-darwin-amd64-build
COPY --from=generate / /
COPY --from=embed-generate / /
WORKDIR /src/cmd/kres
ARG GO_BUILDFLAGS
ARG GO_LDFLAGS
ARG VERSION_PKG="internal/version"
ARG SHA
ARG TAG
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg GOARCH=amd64 GOOS=darwin go build ${GO_BUILDFLAGS} -ldflags "${GO_LDFLAGS} -X ${VERSION_PKG}.Name=kres -X ${VERSION_PKG}.SHA=${SHA} -X ${VERSION_PKG}.Tag=${TAG}" -o /kres-darwin-amd64
# builds kres-darwin-arm64
FROM base AS kres-darwin-arm64-build
COPY --from=generate / /
COPY --from=embed-generate / /
WORKDIR /src/cmd/kres
ARG GO_BUILDFLAGS
ARG GO_LDFLAGS
ARG VERSION_PKG="internal/version"
ARG SHA
ARG TAG
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg GOARCH=arm64 GOOS=darwin go build ${GO_BUILDFLAGS} -ldflags "${GO_LDFLAGS} -X ${VERSION_PKG}.Name=kres -X ${VERSION_PKG}.SHA=${SHA} -X ${VERSION_PKG}.Tag=${TAG}" -o /kres-darwin-arm64
# builds kres-linux-amd64
FROM base AS kres-linux-amd64-build
COPY --from=generate / /
@@ -120,15 +144,42 @@ COPY --from=embed-generate / /
WORKDIR /src/cmd/kres
ARG GO_BUILDFLAGS
ARG GO_LDFLAGS
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go build ${GO_BUILDFLAGS} -ldflags "${GO_LDFLAGS}" -o /kres-linux-amd64
ARG VERSION_PKG="internal/version"
ARG SHA
ARG TAG
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg GOARCH=amd64 GOOS=linux go build ${GO_BUILDFLAGS} -ldflags "${GO_LDFLAGS} -X ${VERSION_PKG}.Name=kres -X ${VERSION_PKG}.SHA=${SHA} -X ${VERSION_PKG}.Tag=${TAG}" -o /kres-linux-amd64
# builds kres-linux-arm64
FROM base AS kres-linux-arm64-build
COPY --from=generate / /
COPY --from=embed-generate / /
WORKDIR /src/cmd/kres
ARG GO_BUILDFLAGS
ARG GO_LDFLAGS
ARG VERSION_PKG="internal/version"
ARG SHA
ARG TAG
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg GOARCH=arm64 GOOS=linux go build ${GO_BUILDFLAGS} -ldflags "${GO_LDFLAGS} -X ${VERSION_PKG}.Name=kres -X ${VERSION_PKG}.SHA=${SHA} -X ${VERSION_PKG}.Tag=${TAG}" -o /kres-linux-arm64
FROM scratch AS kres-darwin-amd64
COPY --from=kres-darwin-amd64-build /kres-darwin-amd64 /kres-darwin-amd64
FROM scratch AS kres-darwin-arm64
COPY --from=kres-darwin-arm64-build /kres-darwin-arm64 /kres-darwin-arm64
FROM scratch AS kres-linux-amd64
COPY --from=kres-linux-amd64-build /kres-linux-amd64 /kres-linux-amd64
FROM scratch AS kres-linux-arm64
COPY --from=kres-linux-arm64-build /kres-linux-arm64 /kres-linux-arm64
FROM kres-linux-${TARGETARCH} AS kres
FROM scratch AS kres-all
COPY --from=kres-darwin-amd64 / /
COPY --from=kres-darwin-arm64 / /
COPY --from=kres-linux-amd64 / /
COPY --from=kres-linux-arm64 / /
FROM scratch AS image-kres
ARG TARGETARCH

View File

@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2023-09-04T14:41:14Z by kres 0c12fbf.
# Generated on 2023-09-05T19:02:56Z by kres 0d3003d-dirty.
# common variables
@@ -163,6 +163,20 @@ unit-tests-race: ## Performs unit tests with race detection enabled.
coverage: ## Upload coverage data to codecov.io.
bash -c "bash <(curl -s https://codecov.io/bash) -f $(ARTIFACTS)/coverage-unit-tests.txt -X fix"
.PHONY: $(ARTIFACTS)/kres-darwin-amd64
$(ARTIFACTS)/kres-darwin-amd64:
@$(MAKE) local-kres-darwin-amd64 DEST=$(ARTIFACTS)
.PHONY: kres-darwin-amd64
kres-darwin-amd64: $(ARTIFACTS)/kres-darwin-amd64 ## Builds executable for kres-darwin-amd64.
.PHONY: $(ARTIFACTS)/kres-darwin-arm64
$(ARTIFACTS)/kres-darwin-arm64:
@$(MAKE) local-kres-darwin-arm64 DEST=$(ARTIFACTS)
.PHONY: kres-darwin-arm64
kres-darwin-arm64: $(ARTIFACTS)/kres-darwin-arm64 ## Builds executable for kres-darwin-arm64.
.PHONY: $(ARTIFACTS)/kres-linux-amd64
$(ARTIFACTS)/kres-linux-amd64:
@$(MAKE) local-kres-linux-amd64 DEST=$(ARTIFACTS)
@@ -170,8 +184,15 @@ $(ARTIFACTS)/kres-linux-amd64:
.PHONY: kres-linux-amd64
kres-linux-amd64: $(ARTIFACTS)/kres-linux-amd64 ## Builds executable for kres-linux-amd64.
.PHONY: $(ARTIFACTS)/kres-linux-arm64
$(ARTIFACTS)/kres-linux-arm64:
@$(MAKE) local-kres-linux-arm64 DEST=$(ARTIFACTS)
.PHONY: kres-linux-arm64
kres-linux-arm64: $(ARTIFACTS)/kres-linux-arm64 ## Builds executable for kres-linux-arm64.
.PHONY: kres
kres: kres-linux-amd64 ## Builds executables for kres.
kres: kres-darwin-amd64 kres-darwin-arm64 kres-linux-amd64 kres-linux-arm64 ## Builds executables for kres.
.PHONY: lint-markdown
lint-markdown: ## Runs markdownlint.

View File

@@ -15,6 +15,7 @@ import (
"github.com/siderolabs/kres/internal/output/conform"
"github.com/siderolabs/kres/internal/output/dockerfile"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/github"
"github.com/siderolabs/kres/internal/output/gitignore"
"github.com/siderolabs/kres/internal/output/golangci"
@@ -53,7 +54,6 @@ func runGen() error {
output.Wrap[golangci.Compiler](golangci.NewOutput()),
output.Wrap[license.Compiler](license.NewOutput()),
output.Wrap[gitignore.Compiler](gitignore.NewOutput()),
output.Wrap[drone.Compiler](drone.NewOutput()),
output.Wrap[codecov.Compiler](codecov.NewOutput()),
output.Wrap[release.Compiler](release.NewOutput()),
output.Wrap[markdownlint.Compiler](markdownlint.NewOutput()),
@@ -82,6 +82,13 @@ func runGen() error {
return err
}
switch options.CIProvider {
case "drone":
outputs = append(outputs, output.Wrap[drone.Compiler](drone.NewOutput()))
case "ghaction":
outputs = append(outputs, output.Wrap[ghworkflow.Compiler](ghworkflow.NewOutput()))
}
if err := proj.Compile(outputs); err != nil {
return err
}

View File

@@ -6,6 +6,13 @@
package config
const (
// CIProviderDrone is the drone ci provider.
CIProviderDrone = "drone"
// CIProviderGitHubActions is the github actions ci provider.
CIProviderGitHubActions = "ghaction"
// CheckOutActionVersion is the version of checkout github action.
// renovate: datasource=github-releases extractVersion=^(?<version>v\d+)\.\d+\.\d+$ depName=actions/checkout
CheckOutActionVersion = "v3"
// DeepCopyVersion is the version of deepcopy.
// renovate: datasource=go depName=github.com/siderolabs/deep-copy
DeepCopyVersion = "v0.5.5"
@@ -28,7 +35,7 @@ const (
// renovate: datasource=docker versioning=docker depName=golang
GolangContainerImageVersion = "1.21-alpine"
// GoVersion is the version of Go.
// renovate: datasource=github-tags extractVersion=^v(?<version>.*)$ versioning=loose depName=golang/go
// renovate: datasource=github-tags extractVersion=^go(?<version>.*)$ depName=golang/go
GoVersion = "1.21"
// GrpcGatewayVersion is the version of grpc-gateway.
// renovate: datasource=go depName=github.com/grpc-ecosystem/grpc-gateway
@@ -36,6 +43,9 @@ const (
// GrpcGoVersion is the version of grpc.
// renovate: datasource=go depName=google.golang.org/grpc/cmd/protoc-gen-go-grpc
GrpcGoVersion = "v1.3.0"
// LoginActionVersion is the version of login github action.
// renovate: datasource=github-releases extractVersion=^(?<version>v\d+)\.\d+\.\d+$ depName=docker/login-action
LoginActionVersion = "v2"
// MardownLintCLIVersion is the version of markdownlint.
// renovate: datasource=npm depName=markdownlint-cli
MardownLintCLIVersion = "0.35.0"
@@ -44,16 +54,25 @@ const (
NodeContainerImageVersion = "20.5.1-alpine3.18"
// PkgsVersion is the version of pkgs.
// renovate: datasource=github-tags depName=siderolabs/pkgs
PkgsVersion = "v1.5.0"
PkgsVersion = "v1.6.0-alpha.0-10-gd3d7d29"
// ProtobufGoVersion is the version of protobuf.
// renovate: datasource=go depName=google.golang.org/protobuf/cmd/protoc-gen-go
ProtobufGoVersion = "v1.31.0"
// ProtobufTSGatewayVersion is the version of protobuf-ts.
// renovate: datasource=go depName=github.com/siderolabs/protoc-gen-grpc-gateway-ts
ProtobufTSGatewayVersion = "v1.2.0"
// ReleaseActionVersion is the version of release github action.
// renovate: datasource=github-releases extractVersion=^(?<version>v\d+)\.\d+\.\d+$ depName=crazy-max/ghaction-github-release
ReleaseActionVersion = "v1"
// SentencesPerLineVersion is the version of sentences-per-line.
// renovate: datasource=npm depName=sentences-per-line
SentencesPerLineVersion = "0.2.1"
// SetupBuildxActionVersion is the version of setup-buildx github action.
// renovate: datasource=github-releases extractVersion=^(?<version>v\d+)\.\d+\.\d+$ depName=docker/setup-buildx-action
SetupBuildxActionVersion = "v2"
// SlackNotifyActionVersion is the version of slack notify github action.
// renovate: datasource=github-releases extractVersion=^(?<version>v\d+)\.\d+\.\d+$ depName=slackapi/slack-github-action
SlackNotifyActionVersion = "v1"
// VTProtobufVersion is the version of vtprotobuf.
// renovate: datasource=go depName=github.com/planetscale/vtprotobuf
VTProtobufVersion = "v0.4.0"

View File

@@ -34,7 +34,7 @@ func NewOutput() *Output {
target: 50,
}
output.FileAdapter.FileWriter = output
output.FileWriter = output
return output
}

View File

@@ -40,7 +40,7 @@ type Output struct {
func NewOutput() *Output {
output := &Output{}
output.FileAdapter.FileWriter = output
output.FileWriter = output
return output
}

View File

@@ -36,7 +36,7 @@ type Output struct {
func NewOutput() *Output {
output := &Output{}
output.FileAdapter.FileWriter = output
output.FileWriter = output
return output
}

View File

@@ -125,7 +125,7 @@ func NewOutput() *Output {
output.manifest.Resources = append(output.manifest.Resources, output.defaultPipeline)
output.FileAdapter.FileWriter = output
output.FileWriter = output
return output
}

View File

@@ -0,0 +1,11 @@
[worker.oci]
gc = true
gckeepstorage = 100000 # 100 GiB
[[worker.oci.gcpolicy]]
keepBytes = 32212254720 # 30 GiB
keepDuration = 604800
filters = [ "type==source.local", "type==exec.cachemount", "type==source.git.checkout"]
[[worker.oci.gcpolicy]]
all = true
keepBytes = 107374182400 # 100 GiB

View File

@@ -0,0 +1,189 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Package ghworkflow implements output to .github/workflows/ci.yaml.
package ghworkflow
import (
_ "embed"
"fmt"
"io"
"strings"
"gopkg.in/yaml.v3"
"github.com/siderolabs/kres/internal/config"
"github.com/siderolabs/kres/internal/output"
)
const (
hostedRunner = "self-hosted"
filename = ".github/workflows/ci.yaml"
internalRegistry = "registry.dev.siderolabs.io"
cacheImagRef = "${GITHUB_REPOSITORY}:buildcache"
cacheType = "type=registry,ref=" + internalRegistry + "/" + cacheImagRef
)
//go:embed files/buildkitd.toml
var buildkitdConfig string
// Output implements GitHub Actions project config generation.
type Output struct {
output.FileAdapter
workflow *Workflow
}
// NewOutput creates new .github/workflows/ci.yaml output.
func NewOutput() *Output {
output := &Output{
workflow: &Workflow{
Name: "default",
On: On{
Push: Push{
Branches: []string{"main"},
Tags: []string{"v*"},
},
PullRequest: PullRequest{},
},
Env: map[string]string{
"CI_ARGS": fmt.Sprintf("--cache-from=%s --cache-to=%s,mode=max", cacheType, cacheType),
},
Jobs: map[string]*Job{
"default": {
RunsOn: []string{hostedRunner, "X64"},
Permissions: map[string]string{
"packages": "write",
"contents": "write",
},
Steps: DefaultSteps(),
},
},
},
}
output.FileWriter = output
return output
}
// AddJob adds job to the workflow.
func (o *Output) AddJob(name string, job *Job) {
o.workflow.Jobs[name] = job
}
// AddStep adds step to the job.
func (o *Output) AddStep(jobName string, steps ...*Step) {
o.workflow.Jobs[jobName].Steps = append(o.workflow.Jobs[jobName].Steps, steps...)
}
// DefaultSteps returns default steps for the workflow.
func DefaultSteps() []*Step {
return []*Step{
{
Name: "checkout",
Uses: fmt.Sprintf("actions/checkout@%s", config.CheckOutActionVersion),
},
{
Name: "Unshallow",
Run: "git fetch --prune --unshallow\n",
},
{
Name: "Set up Docker Buildx",
Uses: fmt.Sprintf("docker/setup-buildx-action@%s", config.SetupBuildxActionVersion),
With: map[string]string{
"config-inline": buildkitdConfig,
},
},
}
}
// MakeStep creates a step with make command.
func MakeStep(name string, args ...string) *Step {
command := fmt.Sprintf("make %s\n", name)
if len(args) > 0 {
command = fmt.Sprintf("make %s %s\n", name, strings.Join(args, " "))
}
return &Step{
Name: name,
Run: command,
}
}
// SetName sets step name.
func (step *Step) SetName(name string) *Step {
step.Name = name
return step
}
// SetEnv sets step environment variables.
func (step *Step) SetEnv(name, value string) *Step {
if step.Env == nil {
step.Env = map[string]string{}
}
step.Env[name] = value
return step
}
// ExceptPullRequest adds condition to skip step on PRs.
func (step *Step) ExceptPullRequest() *Step {
step.If = "github.event_name != 'pull_request'"
return step
}
// OnlyOnTag adds condition to run step only on tags.
func (step *Step) OnlyOnTag() *Step {
step.If = "startsWith(github.ref, 'refs/tags/')"
return step
}
// Compile implements [output.TypedWriter] interface.
func (o *Output) Compile(compiler Compiler) error {
return compiler.CompileGitHubWorkflow(o)
}
// Filenames implements output.FileWriter interface.
func (o *Output) Filenames() []string {
return []string{filename}
}
// GenerateFile implements output.FileWriter interface.
func (o *Output) GenerateFile(filename string, w io.Writer) error {
switch filename {
case filename:
return o.config(w)
default:
panic("unexpected filename: " + filename)
}
}
func (o *Output) config(w io.Writer) error {
encoder := yaml.NewEncoder(w)
defer encoder.Close() //nolint:errcheck
encoder.SetIndent(2)
if err := encoder.Encode(o.workflow); err != nil {
return fmt.Errorf("failed to encode workflow: %w", err)
}
if err := encoder.Close(); err != nil {
return fmt.Errorf("failed to close encoder: %w", err)
}
return nil
}
// Compiler is implemented by project blocks which support GitHub Actions config generation.
type Compiler interface {
CompileGitHubWorkflow(*Output) error
}

View File

@@ -0,0 +1,57 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package ghworkflow
// Workflow represents Github Actions workflow.
//
//nolint:govet
type Workflow struct {
Name string `yaml:"name"`
On On `yaml:"on"`
Env map[string]string `yaml:"env,omitempty"`
Jobs map[string]*Job `yaml:"jobs"`
}
// On represents GitHub Actions event triggers.
type On struct {
Push `yaml:"push"`
PullRequest `yaml:"pull_request"`
}
// Branches represents GitHub Actions branch filters.
type Branches []string
// PullRequest represents GitHub Actions pull request filters.
type PullRequest struct {
Branches `yaml:"branches,omitempty"`
}
// PullRequestTarget represents GitHub Actions pull request target filters.
type PullRequestTarget struct{}
// Push represents GitHub Actions push filters.
type Push struct {
Branches `yaml:"branches"`
Tags []string `yaml:"tags,omitempty"`
}
// Job represents GitHub Actions job.
type Job struct {
Permissions map[string]string `yaml:"permissions,omitempty"`
RunsOn []string `yaml:"runs-on"`
If string `yaml:"if,omitempty"`
Needs []string `yaml:"needs,omitempty"`
Steps []*Step `yaml:"steps"`
}
// Step represents GitHub Actions step.
type Step struct {
Name string `yaml:"name"`
If string `yaml:"if,omitempty"`
Uses string `yaml:"uses,omitempty"`
With map[string]string `yaml:"with,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
Run string `yaml:"run,omitempty"`
}

View File

@@ -27,7 +27,7 @@ type Output struct {
func NewOutput() *Output {
output := &Output{}
output.FileAdapter.FileWriter = output
output.FileWriter = output
return output
}

View File

@@ -41,7 +41,7 @@ type file struct {
func NewOutput() *Output {
output := &Output{}
output.FileAdapter.FileWriter = output
output.FileWriter = output
return output
}

View File

@@ -44,7 +44,7 @@ type Output struct {
func NewOutput() *Output {
output := &Output{}
output.FileAdapter.FileWriter = output
output.FileWriter = output
return output
}

View File

@@ -33,7 +33,7 @@ type Output struct {
func NewOutput() *Output {
output := &Output{}
output.FileAdapter.FileWriter = output
output.FileWriter = output
return output
}

View File

@@ -34,7 +34,7 @@ func NewOutput() *Output {
},
}
output.FileAdapter.FileWriter = output
output.FileWriter = output
return output
}

View File

@@ -40,7 +40,7 @@ type Output struct {
func NewOutput() *Output {
output := &Output{}
output.FileAdapter.FileWriter = output
output.FileWriter = output
return output
}

View File

@@ -112,7 +112,7 @@ func NewOutput() *Output {
templates: map[string]*FileTemplate{},
}
output.FileAdapter.FileWriter = output
output.FileWriter = output
return output
}

View File

@@ -57,6 +57,10 @@ func (builder *builder) build() error {
detect: builder.DetectGit,
build: builder.BuildGit,
},
{
detect: builder.DetectCI,
build: builder.BuildCI,
},
{
detect: builder.DetectJS,
build: builder.BuildJS,
@@ -112,11 +116,12 @@ func (builder *builder) build() error {
rekres := common.NewReKres(builder.meta)
makeHelp := common.NewMakeHelp(builder.meta)
conformance := common.NewConformance(builder.meta)
slackNotify := common.NewSlackNotify(builder.meta)
release.AddInput(builder.targets...)
builder.proj.AddTarget(builder.targets...)
builder.proj.AddTarget(rekres, all, makeHelp, release, conformance)
builder.proj.AddTarget(rekres, all, makeHelp, release, slackNotify, conformance)
return nil
}

View File

@@ -0,0 +1,40 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package auto
import (
"fmt"
"github.com/siderolabs/kres/internal/config"
)
// DetectCI checks the ci settings.
func (builder *builder) DetectCI() (bool, error) {
return true, nil
}
// BuildCI builds the ci settings.
func (builder *builder) BuildCI() error {
var ci CI
if err := builder.meta.Config.Load(&ci); err != nil {
return err
}
if ci.Provider == "" {
ci.Provider = config.CIProviderGitHubActions
}
switch ci.Provider {
case config.CIProviderDrone:
case config.CIProviderGitHubActions:
default:
return fmt.Errorf("unknown ci provider: %s", ci.Provider)
}
builder.meta.CIProvider = ci.Provider
return nil
}

View File

@@ -32,3 +32,8 @@ type CustomStep struct {
Inputs []string `yaml:"inputs"`
Toplevel bool `yaml:"toplevel"`
}
// CI defines CI settings.
type CI struct {
Provider string `yaml:"provider"`
}

View File

@@ -156,7 +156,7 @@ func (builder *builder) processDirectory(path string) error {
rootPath := filepath.Join(builder.rootPath, dir)
if builder.meta.VersionPackagePath == "" && builder.meta.VersionPackage == "" {
if builder.meta.VersionPackagePath == "" {
for _, candidate := range []string{"pkg/version", "internal/version"} {
exists, err := directoryExists(dir, candidate)
if err != nil {
@@ -164,7 +164,7 @@ func (builder *builder) processDirectory(path string) error {
}
if exists {
builder.meta.VersionPackage = filepath.Join(canonicalPath, filepath.Join(dir, candidate))
builder.meta.VersionPackagePath = filepath.Join(canonicalPath, filepath.Join(dir, candidate))
}
}
}

View File

@@ -0,0 +1,60 @@
{
"attachments": [
{
"color": "${{ job.status == 'success' && '#2EB886' || job.status == 'failure' && '#A30002' || '#FFCC00' }}",
"fallback": "test",
"blocks": [
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "${{ github.event_name == 'pull_request' && format('*Pull Request:* {0} (`{1}`)\n<{2}|{3}>', github.repository, github.base_ref, github.event.pull_request.html_url, github.event.pull_request.title) || format('*Build:* {0}#{1} (`{2}`)', github.repository, github.sha, github.ref_name) }}"
},
{
"type": "mrkdwn",
"text": "*Status:*\n`${{ job.status }}`"
}
]
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Author:*\n`${{ github.actor }}`"
},
{
"type": "mrkdwn",
"text": "*Event:*\n`${{ github.event_name }}`"
}
]
},
{
"type": "divider"
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Logs"
},
"url": "${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}"
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Commit"
},
"url": "${{ github.event.repository.html_url }}/commit/${{ github.sha }}"
}
]
}
]
}
]
}

View File

@@ -7,10 +7,12 @@ package common
import (
"fmt"
"github.com/siderolabs/kres/internal/config"
"github.com/siderolabs/kres/internal/dag"
"github.com/siderolabs/kres/internal/output/dockerfile"
"github.com/siderolabs/kres/internal/output/dockerfile/step"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/makefile"
"github.com/siderolabs/kres/internal/project/meta"
)
@@ -21,10 +23,10 @@ type Image struct {
meta *meta.Options
DroneExtraEnvironment map[string]string `yaml:"droneExtraEnvironment"`
BaseImage string `yaml:"baseImage"`
AdditionalImages []string `yaml:"additionalImages"`
CopyFrom []struct {
ExtraEnvironment map[string]string `yaml:"extraEnvironment"`
BaseImage string `yaml:"baseImage"`
AdditionalImages []string `yaml:"additionalImages"`
CopyFrom []struct {
Stage string `yaml:"stage"`
Source string `yaml:"source"`
Destination string `yaml:"destination"`
@@ -67,7 +69,7 @@ func (image *Image) CompileDrone(output *drone.Output) error {
DockerLogin().
DependsOn(image.Name())
for k, v := range image.DroneExtraEnvironment {
for k, v := range image.ExtraEnvironment {
step.Environment(k, v)
}
@@ -82,7 +84,7 @@ func (image *Image) CompileDrone(output *drone.Output) error {
DockerLogin().
DependsOn(fmt.Sprintf("push-%s", image.ImageName))
for k, v := range image.DroneExtraEnvironment {
for k, v := range image.ExtraEnvironment {
step.Environment(k, v)
}
@@ -92,6 +94,56 @@ func (image *Image) CompileDrone(output *drone.Output) error {
return nil
}
// CompileGitHubWorkflow implements ghworkflow.Compiler.
func (image *Image) CompileGitHubWorkflow(output *ghworkflow.Output) error {
loginStep := &ghworkflow.Step{
Name: "Login to registry",
Uses: fmt.Sprintf("docker/login-action@%s", config.LoginActionVersion),
With: map[string]string{
"registry": "ghcr.io",
"username": "${{ github.repository_owner }}",
"password": "${{ secrets.GITHUB_TOKEN }}",
},
}
loginStep.ExceptPullRequest()
pushStep := ghworkflow.MakeStep(image.Name()).
SetName(fmt.Sprintf("push-%s", image.ImageName)).
SetEnv("PUSH", "true").
ExceptPullRequest()
for k, v := range image.ExtraEnvironment {
pushStep.SetEnv(k, v)
}
steps := []*ghworkflow.Step{
loginStep,
ghworkflow.MakeStep(image.Name()),
pushStep,
}
if image.PushLatest {
pushStep := ghworkflow.MakeStep(image.Name(), "TAG=latest").
SetName(fmt.Sprintf("push-%s-latest", image.ImageName)).
SetEnv("PUSH", "true").
ExceptPullRequest()
for k, v := range image.ExtraEnvironment {
pushStep.SetEnv(k, v)
}
steps = append(
steps,
pushStep,
)
}
output.AddStep("default", steps...)
return nil
}
// CompileMakefile implements makefile.Compiler.
func (image *Image) CompileMakefile(output *makefile.Output) error {
output.Target(image.Name()).

View File

@@ -11,6 +11,7 @@ import (
"github.com/siderolabs/kres/internal/output/dockerfile"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/makefile"
"github.com/siderolabs/kres/internal/project/common"
)
@@ -19,4 +20,5 @@ func TestImageInterfaces(t *testing.T) {
assert.Implements(t, (*makefile.Compiler)(nil), new(common.Image))
assert.Implements(t, (*dockerfile.Compiler)(nil), new(common.Image))
assert.Implements(t, (*drone.Compiler)(nil), new(common.Image))
assert.Implements(t, (*ghworkflow.Compiler)(nil), new(common.Image))
}

View File

@@ -7,6 +7,7 @@ package common
import (
"github.com/siderolabs/kres/internal/dag"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/makefile"
"github.com/siderolabs/kres/internal/project/meta"
)
@@ -36,6 +37,16 @@ func (lint *Lint) CompileDrone(output *drone.Output) error {
return nil
}
// CompileGitHubWorkflow implements ghworkflow.Compiler.
func (lint *Lint) CompileGitHubWorkflow(output *ghworkflow.Output) error {
output.AddStep(
"default",
ghworkflow.MakeStep("lint"),
)
return nil
}
// CompileMakefile implements makefile.Compiler.
func (lint *Lint) CompileMakefile(output *makefile.Output) error {
output.Target("lint").Description("Run all linters for the project.").

View File

@@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/makefile"
"github.com/siderolabs/kres/internal/project/common"
)
@@ -17,4 +18,5 @@ import (
func TestLintInterfaces(t *testing.T) {
assert.Implements(t, (*makefile.Compiler)(nil), new(common.Lint))
assert.Implements(t, (*drone.Compiler)(nil), new(common.Lint))
assert.Implements(t, (*ghworkflow.Compiler)(nil), new(common.Lint))
}

View File

@@ -5,17 +5,21 @@
package common
import (
"fmt"
"path/filepath"
"strings"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/kres/internal/config"
"github.com/siderolabs/kres/internal/dag"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/makefile"
"github.com/siderolabs/kres/internal/project/meta"
)
// Release provides common releasr target.
// Release provides common release target.
type Release struct {
meta *meta.Options
dag.BaseNode
@@ -59,6 +63,45 @@ func (release *Release) CompileDrone(output *drone.Output) error {
return nil
}
// CompileGitHubWorkflow implements ghworkflow.Compiler.
func (release *Release) CompileGitHubWorkflow(output *ghworkflow.Output) error {
artifacts := xslices.Map(release.Artifacts, func(artifact string) string {
return filepath.Join(release.meta.ArtifactsPath, artifact)
})
checkSumCommands := []string{
fmt.Sprintf("sha256sum %s > %s", strings.Join(artifacts, " "), filepath.Join(release.meta.ArtifactsPath, "sha256sum.txt")),
fmt.Sprintf("sha512sum %s > %s", strings.Join(artifacts, " "), filepath.Join(release.meta.ArtifactsPath, "sha512sum.txt")),
}
checkSumStep := &ghworkflow.Step{
Name: "Generate Checksums",
Run: strings.Join(checkSumCommands, "\n") + "\n",
}
releaseStep := &ghworkflow.Step{
Name: "Release",
Uses: fmt.Sprintf("crazy-max/ghaction-github-release@%s", config.ReleaseActionVersion),
With: map[string]string{
"files": strings.Join(artifacts, "\n") + "\n" + filepath.Join(release.meta.ArtifactsPath, "sha*.txt"),
"body_path": filepath.Join(release.meta.ArtifactsPath, "RELEASE_NOTES.md"),
"draft": "true",
},
}
output.AddStep(
"default",
checkSumStep.
OnlyOnTag(),
ghworkflow.MakeStep("release-notes").
OnlyOnTag(),
releaseStep.
OnlyOnTag(),
)
return nil
}
// CompileMakefile implements makefile.Compiler.
func (release *Release) CompileMakefile(output *makefile.Output) error {
output.Target("release-notes").

View File

@@ -0,0 +1,22 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package common_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/makefile"
"github.com/siderolabs/kres/internal/project/common"
)
func TestReleaseInterfaces(t *testing.T) {
assert.Implements(t, (*makefile.Compiler)(nil), new(common.Release))
assert.Implements(t, (*drone.Compiler)(nil), new(common.Release))
assert.Implements(t, (*ghworkflow.Compiler)(nil), new(common.Release))
}

View File

@@ -13,6 +13,7 @@ import (
"github.com/google/go-github/v53/github"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/kres/internal/config"
"github.com/siderolabs/kres/internal/dag"
"github.com/siderolabs/kres/internal/output/conform"
"github.com/siderolabs/kres/internal/output/license"
@@ -60,9 +61,6 @@ func NewRepository(meta *meta.Options) *Repository {
meta: meta,
MainBranch: meta.MainBranch,
EnforceContexts: []string{
"continuous-integration/drone/pr",
},
EnableConform: true,
ConformWebhookURL: "https://conform.dev.talos-systems.io/github",
@@ -138,6 +136,7 @@ func (r *Repository) CompileGitHub(client *github.Client) error {
return r.inviteBot(client)
}
//nolint:gocyclo,cyclop
func (r *Repository) enableBranchProtection(client *github.Client) error {
branchProtection, resp, err := client.Repositories.GetBranchProtection(context.Background(), r.meta.GitHubOrganization, r.meta.GitHubRepository, r.MainBranch)
if err != nil {
@@ -147,6 +146,14 @@ func (r *Repository) enableBranchProtection(client *github.Client) error {
}
enforceContexts := r.EnforceContexts
switch r.meta.CIProvider {
case config.CIProviderDrone:
enforceContexts = append(enforceContexts, "continuous-integration/drone/pr")
case config.CIProviderGitHubActions:
enforceContexts = append(enforceContexts, "default")
}
if r.EnableConform {
enforceContexts = append(enforceContexts,
"conform/commit/commit-body",

View File

@@ -0,0 +1,51 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package common
import (
_ "embed"
"github.com/siderolabs/kres/internal/dag"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/project/meta"
)
//nolint:unused
//go:embed files/slack-notify-payload.json
var slackNotifyPayloadJSON string
// SlackNotify provides common Slack notification target.
type SlackNotify struct {
meta *meta.Options
dag.BaseNode
}
// NewSlackNotify initializes SlackNotify.
func NewSlackNotify(meta *meta.Options) *SlackNotify {
return &SlackNotify{
meta: meta,
}
}
// CompileGitHubWorkflow implements ghworkflow.Compiler.
func (slacknotify *SlackNotify) CompileGitHubWorkflow(_ *ghworkflow.Output) error {
// TODO: enable once we figure out secrets for forks.
// output.AddStep(
// "default",
// &ghworkflow.Step{
// Name: "Slack Notify",
// If: "always()",
// Uses: fmt.Sprintf("slackapi/slack-github-action@%s", config.SlackNotifyActionVersion),
// Env: map[string]string{
// "SLACK_BOT_TOKEN": "${{ secrets.SLACK_BOT_TOKEN }}",
// },
// With: map[string]string{
// "channel-id": "proj-talos-maintainers",
// "payload": slackNotifyPayloadJSON,
// },
// },
// )
return nil
}

View File

@@ -14,6 +14,7 @@ import (
"github.com/siderolabs/kres/internal/output/dockerfile"
"github.com/siderolabs/kres/internal/output/dockerfile/step"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/makefile"
"github.com/siderolabs/kres/internal/project/meta"
)
@@ -82,9 +83,9 @@ func (build *Build) CompileDockerfile(output *dockerfile.Output) error {
ldflags := "${GO_LDFLAGS}"
if build.meta.VersionPackagePath == "" && build.meta.VersionPackage != "" {
if build.meta.VersionPackagePath != "" {
stage.
Step(step.Arg(fmt.Sprintf("VERSION_PKG=\"%s\"", build.meta.VersionPackage))).
Step(step.Arg(fmt.Sprintf("VERSION_PKG=\"%s\"", build.meta.VersionPackagePath))).
Step(step.Arg("SHA")).
Step(step.Arg("TAG"))
@@ -139,6 +140,16 @@ func (build *Build) CompileDrone(output *drone.Output) error {
return nil
}
// CompileGitHubWorkflow implements ghworkflow.Compiler.
func (build *Build) CompileGitHubWorkflow(output *ghworkflow.Output) error {
output.AddStep(
"default",
ghworkflow.MakeStep(build.Name()),
)
return nil
}
// CompileMakefile implements makefile.Compiler.
func (build *Build) CompileMakefile(output *makefile.Output) error {
artifacts := build.getArtifacts()

View File

@@ -11,6 +11,7 @@ import (
"github.com/siderolabs/kres/internal/output/dockerfile"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/makefile"
"github.com/siderolabs/kres/internal/project/golang"
)
@@ -19,4 +20,5 @@ func TestBuildInterfaces(t *testing.T) {
assert.Implements(t, (*dockerfile.Compiler)(nil), new(golang.Build))
assert.Implements(t, (*makefile.Compiler)(nil), new(golang.Build))
assert.Implements(t, (*drone.Compiler)(nil), new(golang.Build))
assert.Implements(t, (*ghworkflow.Compiler)(nil), new(golang.Build))
}

View File

@@ -13,6 +13,7 @@ import (
"github.com/siderolabs/kres/internal/output/dockerfile"
"github.com/siderolabs/kres/internal/output/dockerfile/step"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/makefile"
"github.com/siderolabs/kres/internal/project/common"
"github.com/siderolabs/kres/internal/project/meta"
@@ -168,6 +169,13 @@ func (toolchain *Toolchain) CompileDrone(output *drone.Output) error {
return nil
}
// CompileGitHubWorkflow implements ghworkflow.Compiler.
func (toolchain *Toolchain) CompileGitHubWorkflow(output *ghworkflow.Output) error {
output.AddStep("default", ghworkflow.MakeStep("base"))
return nil
}
// CompileDockerfile implements dockerfile.Compiler.
func (toolchain *Toolchain) CompileDockerfile(output *dockerfile.Output) error {
output.Arg(step.Arg("TOOLCHAIN"))

View File

@@ -11,6 +11,7 @@ import (
"github.com/siderolabs/kres/internal/output/dockerfile"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/makefile"
"github.com/siderolabs/kres/internal/project/golang"
)
@@ -19,5 +20,6 @@ func TestToolchainInterfaces(t *testing.T) {
assert.Implements(t, (*dockerfile.Compiler)(nil), new(golang.Toolchain))
assert.Implements(t, (*makefile.Compiler)(nil), new(golang.Toolchain))
assert.Implements(t, (*drone.Compiler)(nil), new(golang.Toolchain))
assert.Implements(t, (*ghworkflow.Compiler)(nil), new(golang.Toolchain))
assert.Implements(t, (*makefile.SkipAsMakefileDependency)(nil), new(golang.Toolchain))
}

View File

@@ -12,6 +12,7 @@ import (
"github.com/siderolabs/kres/internal/output/dockerfile"
"github.com/siderolabs/kres/internal/output/dockerfile/step"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/makefile"
"github.com/siderolabs/kres/internal/project/meta"
)
@@ -132,3 +133,14 @@ func (tests *UnitTests) CompileDrone(output *drone.Output) error {
return nil
}
// CompileGitHubWorkflow implements ghworkflow.Compiler.
func (tests *UnitTests) CompileGitHubWorkflow(output *ghworkflow.Output) error {
output.AddStep(
"default",
ghworkflow.MakeStep(tests.Name()),
ghworkflow.MakeStep(fmt.Sprintf("%s-race", tests.Name())),
)
return nil
}

View File

@@ -11,6 +11,7 @@ import (
"github.com/siderolabs/kres/internal/output/dockerfile"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/makefile"
"github.com/siderolabs/kres/internal/project/golang"
)
@@ -19,4 +20,5 @@ func TestUnitTestsInterfaces(t *testing.T) {
assert.Implements(t, (*dockerfile.Compiler)(nil), new(golang.UnitTests))
assert.Implements(t, (*makefile.Compiler)(nil), new(golang.UnitTests))
assert.Implements(t, (*drone.Compiler)(nil), new(golang.UnitTests))
assert.Implements(t, (*ghworkflow.Compiler)(nil), new(golang.UnitTests))
}

View File

@@ -12,6 +12,7 @@ import (
"github.com/siderolabs/kres/internal/output/dockerfile"
"github.com/siderolabs/kres/internal/output/dockerfile/step"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/makefile"
"github.com/siderolabs/kres/internal/output/template"
"github.com/siderolabs/kres/internal/project/js/templates"
@@ -87,6 +88,13 @@ func (build *Build) CompileDrone(output *drone.Output) error {
return nil
}
// CompileGitHubWorkflow implements ghworkflow.Compiler.
func (build *Build) CompileGitHubWorkflow(output *ghworkflow.Output) error {
output.AddStep("default", ghworkflow.MakeStep(build.Name()))
return nil
}
// CompileMakefile implements makefile.Compiler.
func (build *Build) CompileMakefile(output *makefile.Output) error {
output.VariableGroup(makefile.VariableGroupCommon).

View File

@@ -11,6 +11,7 @@ import (
"github.com/siderolabs/kres/internal/output/dockerfile"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/makefile"
"github.com/siderolabs/kres/internal/output/template"
"github.com/siderolabs/kres/internal/project/js"
@@ -21,5 +22,6 @@ func TestBuildInterfaces(t *testing.T) {
assert.Implements(t, (*dockerfile.Generator)(nil), new(js.Build))
assert.Implements(t, (*makefile.Compiler)(nil), new(js.Build))
assert.Implements(t, (*drone.Compiler)(nil), new(js.Build))
assert.Implements(t, (*ghworkflow.Compiler)(nil), new(js.Build))
assert.Implements(t, (*template.Compiler)(nil), new(js.Build))
}

View File

@@ -14,6 +14,7 @@ import (
"github.com/siderolabs/kres/internal/output/dockerfile"
"github.com/siderolabs/kres/internal/output/dockerfile/step"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/gitignore"
"github.com/siderolabs/kres/internal/output/makefile"
"github.com/siderolabs/kres/internal/output/template"
@@ -104,6 +105,13 @@ func (toolchain *Toolchain) CompileDrone(output *drone.Output) error {
return nil
}
// CompileGitHubWorkflow implements ghworkflow.Compiler.
func (toolchain *Toolchain) CompileGitHubWorkflow(output *ghworkflow.Output) error {
output.AddStep("default", ghworkflow.MakeStep("js"))
return nil
}
// CompileDockerfile implements dockerfile.Compiler.
func (toolchain *Toolchain) CompileDockerfile(output *dockerfile.Output) error {
output.Arg(step.Arg("JS_TOOLCHAIN"))

View File

@@ -11,6 +11,7 @@ import (
"github.com/siderolabs/kres/internal/output/dockerfile"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/makefile"
"github.com/siderolabs/kres/internal/output/template"
"github.com/siderolabs/kres/internal/project/js"
@@ -21,5 +22,6 @@ func TestToolchainInterfaces(t *testing.T) {
assert.Implements(t, (*template.Compiler)(nil), new(js.Toolchain))
assert.Implements(t, (*makefile.Compiler)(nil), new(js.Toolchain))
assert.Implements(t, (*drone.Compiler)(nil), new(js.Toolchain))
assert.Implements(t, (*ghworkflow.Compiler)(nil), new(js.Toolchain))
assert.Implements(t, (*makefile.SkipAsMakefileDependency)(nil), new(js.Toolchain))
}

View File

@@ -9,6 +9,7 @@ import (
"github.com/siderolabs/kres/internal/output/dockerfile"
"github.com/siderolabs/kres/internal/output/dockerfile/step"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/makefile"
"github.com/siderolabs/kres/internal/project/meta"
)
@@ -61,3 +62,13 @@ func (tests *UnitTests) CompileDrone(output *drone.Output) error {
return nil
}
// CompileGitHubWorkflow implements ghworkflow.Compiler.
func (tests *UnitTests) CompileGitHubWorkflow(output *ghworkflow.Output) error {
output.AddStep(
"default",
ghworkflow.MakeStep(tests.Name()),
)
return nil
}

View File

@@ -11,6 +11,7 @@ import (
"github.com/siderolabs/kres/internal/output/dockerfile"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/makefile"
"github.com/siderolabs/kres/internal/project/js"
)
@@ -19,4 +20,5 @@ func TestUnitTestsInterfaces(t *testing.T) {
assert.Implements(t, (*dockerfile.Compiler)(nil), new(js.UnitTests))
assert.Implements(t, (*makefile.Compiler)(nil), new(js.UnitTests))
assert.Implements(t, (*drone.Compiler)(nil), new(js.UnitTests))
assert.Implements(t, (*ghworkflow.Compiler)(nil), new(js.UnitTests))
}

View File

@@ -26,11 +26,6 @@ type Options struct { //nolint:govet
// CanonicalPaths, import path for Go projects.
CanonicalPaths []string
// VersionPackage is a canonical path to version package (if any).
//
// Deprecared: use VersionPackagePath instead.
VersionPackage string
// VersionPackagePath is a canonical path to version package directory.
VersionPackagePath string
@@ -87,6 +82,9 @@ type Options struct { //nolint:govet
// ArtifactsPath binary output path.
ArtifactsPath string
// CIProvider specifies the CI provider. Currently drone/ghaction is supported.
CIProvider string
}
// Command defines Golang executable build configuration.

View File

@@ -10,6 +10,7 @@ import (
"github.com/siderolabs/kres/internal/dag"
"github.com/siderolabs/kres/internal/output/codecov"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/makefile"
"github.com/siderolabs/kres/internal/project/meta"
)
@@ -51,6 +52,13 @@ func (coverage *CodeCov) CompileDrone(output *drone.Output) error {
return nil
}
// CompileGitHubWorkflow implements ghworkflow.Compiler.
func (coverage *CodeCov) CompileGitHubWorkflow(output *ghworkflow.Output) error {
output.AddStep("default", ghworkflow.MakeStep("coverage"))
return nil
}
// CompileMakefile implements makefile.Compiler.
func (coverage *CodeCov) CompileMakefile(output *makefile.Output) error {
if !coverage.Enabled {

View File

@@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/siderolabs/kres/internal/output/drone"
"github.com/siderolabs/kres/internal/output/ghworkflow"
"github.com/siderolabs/kres/internal/output/makefile"
"github.com/siderolabs/kres/internal/project/service"
)
@@ -17,4 +18,5 @@ import (
func TestCodeCovInterfaces(t *testing.T) {
assert.Implements(t, (*makefile.Compiler)(nil), new(service.CodeCov))
assert.Implements(t, (*drone.Compiler)(nil), new(service.CodeCov))
assert.Implements(t, (*ghworkflow.Compiler)(nil), new(service.CodeCov))
}