Skip to content
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

move ta-generator to task-generator directory #1439

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/check-buildah-remote.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
with:
go-version-file: './task-generator/go.mod'
go-version-file: './task-generator/remote/go.mod'
- name: Check buildah remote
run: |
./hack/generate-buildah-remote.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/checkton.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
# Set to false when re-enabling SARIF uploads
fail-on-findings: true
find-copies-harder: true
exclude-regex: ^ta-generator
exclude-regex: ^task-generator

# Currently, code scanning alerts annoyingly stay open even if you fix them.
# Don't upload SARIF until https://github.com/orgs/community/discussions/132787 is resolved.
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/go-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
strategy:
matrix:
path:
- task-generator
- ta-generator
- task-generator/remote
- task-generator/trusted-artifacts
steps:
- uses: actions/checkout@6d193bf28034eafb982f37bd894289fe649468fc
- uses: actions/setup-go@b26d40294f8ad76fcc90b915dac85892322fe62d
Expand All @@ -28,8 +28,8 @@ jobs:
strategy:
matrix:
path:
- task-generator
- ta-generator
- task-generator/remote
- task-generator/trusted-artifacts
steps:
- uses: actions/checkout@6d193bf28034eafb982f37bd894289fe649468fc
- name: Install Go
Expand Down Expand Up @@ -69,8 +69,8 @@ jobs:
strategy:
matrix:
path:
- task-generator
- ta-generator
- task-generator/remote
- task-generator/trusted-artifacts
steps:
- uses: actions/checkout@6d193bf28034eafb982f37bd894289fe649468fc
- uses: actions/setup-go@b26d40294f8ad76fcc90b915dac85892322fe62d
Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,12 @@ bundle_values.env
*~
*.swp
.checkton.sarif
**/vendor

# expected and got files generated in trusted-artifacts tests when mismatch occurs
task-generator/trusted-artifacts/golden/**/expected
task-generator/trusted-artifacts/golden/**/got
# Generated binaries
task-generator/trusted-artifacts/trusted-artifacts
task-generator/remote/remote

4 changes: 2 additions & 2 deletions hack/generate-buildah-remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ set -euo pipefail

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

cd "${SCRIPTDIR}/../task-generator"
go build -o /tmp/remote-generator ./remote/main.go
cd "${SCRIPTDIR}/../task-generator/remote"
go build -o /tmp/remote-generator main.go

for version in 0.1 0.2; do
/tmp/remote-generator --buildah-task="${SCRIPTDIR}/../task/buildah/${version}/buildah.yaml" \
Expand Down
2 changes: 1 addition & 1 deletion hack/generate-ta-tasks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ROOT_DIR="$(git rev-parse --show-toplevel)"
TASK_DIR="$(realpath "${ROOT_DIR}/task")"

tashbin="$(mktemp --dry-run)"
GOTOOLCHAIN=auto GOSUMDB=sum.golang.org go build -C "${ROOT_DIR}/ta-generator/" -o "${tashbin}"
GOTOOLCHAIN=auto GOSUMDB=sum.golang.org go build -C "${ROOT_DIR}/task-generator/trusted-artifacts" -o "${tashbin}"
trap 'rm "${tashbin}"' EXIT
tash() {
"${tashbin}" "$@"
Expand Down
17 changes: 0 additions & 17 deletions ta-generator/README.md

This file was deleted.

23 changes: 2 additions & 21 deletions task-generator/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
# Task generator
Task generator is a tool used for generating various versions of tasks.

## Buildah remote task generation
The Buildah task builds source code into a container image and pushes the image into container registry using the Buildah tool.
While the standard Buildah task runs directly on the cluster, the remote task is run on a remote host.
This must be used in combination with the Multi Arch Controller, which provides the credentials and host name used to perform the build.

The remote versions of the Buildah task are programmatically generated by this script from the buildah task to keep them in sync. The generated remote tasks should not be manually modified.

### Arguments
- `buildah-task` - The location of the buildah task YAML file (required)
- `remote-task` - The location of the buildah-remote task YAML file to overwrite (required)
- `task-version` - The version of the task to overwrite, e.g. `0.2` (required)

Example usage:
```
go run remote/main.go \
--buildah-task ../task/buildah/0.2/buildah.yaml \
--remote-task ../task/buildah-remote/0.2/buildah-remote.yaml \
--task-version 0.2
```
The Task generator is a collection of tools used for generating various versions of tasks.

Each tool has its own subdirectory with a README.
21 changes: 21 additions & 0 deletions task-generator/remote/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Buildah remote task generation
The Buildah task builds source code into a container image and pushes the image into container registry using the Buildah tool.
While the standard Buildah task runs directly on the cluster, the remote task is run on a remote host.
This must be used in combination with the Multi Arch Controller, which provides the credentials and host name used to perform the build.

The remote versions of the Buildah task are programmatically generated by this script from the buildah task to keep them in sync. The generated remote tasks should not be manually modified.

This tool is used by the `hack/generate-buildah-remote.sh` script.

## Arguments
- `buildah-task` - The location of the buildah task YAML file (required)
- `remote-task` - The location of the buildah-remote task YAML file to overwrite (required)
- `task-version` - The version of the task to overwrite, e.g. `0.2` (required)

Example usage:
```
go run remote/main.go \
--buildah-task ../task/buildah/0.2/buildah.yaml \
--remote-task ../task/buildah-remote/0.2/buildah-remote.yaml \
--task-version 0.2
```
2 changes: 1 addition & 1 deletion task-generator/go.mod → task-generator/remote/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/konflux-ci/build-definitions/task-generator
module github.com/konflux-ci/build-definitions/task-generator/remote

go 1.22.0

Expand Down
File renamed without changes.
30 changes: 30 additions & 0 deletions task-generator/trusted-artifacts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Trusted Artifacts variants generator

## Description

This tool is used for the generation of trusted artifacts variants of a task.
It will process a set of directions in `recipe.yaml` file and
based on that and a set of builtin conventions generate the Tekton Task
definition in YAML format.

This tool is used by the `hack/generate-ta-tasks.sh` script.

## Usage

The tool uses only one argument - path to the `recipe.yaml` file.
These `recipe.yaml` files are stored in the task directories ending with `-oci-ta`.

Usage (from the `task-generator/trusted-artifacts` directory)
```
go run . path/to/recipe.yaml
```

The generated Trusted Artifacts Task is provided on the standard output.

## Testing

There are various included tests in the `golden` folder.
They use the `base.yaml` file which gets modified based on the `recipe.yaml` and is compared to the `ta.yaml`
```
go test ./...
```
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/konflux-ci/build-definitions/ta-generator
module github.com/konflux-ci/build-definitions/task-generator/trusted-artifacts

go 1.22.3

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading