-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate KonfluxGen with prowgen so that after running prowgen we can create PRs for all midstream repositories to add/update/remove Konflux components and applications (to be added pipelines and ImageRepository). Signed-off-by: Pierangelo Di Pilato <[email protected]>
- Loading branch information
Showing
18 changed files
with
850 additions
and
79 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: Generate CI config (template) | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- '**' | ||
push: | ||
branches: | ||
- 'main' | ||
schedule: | ||
- cron: "0 6 * * *" # Daily at 06:00. | ||
workflow_dispatch: # Manual workflow trigger | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
generate-ci: | ||
name: generate-ci | ||
runs-on: ubuntu-latest | ||
env: | ||
GOPATH: ${{ github.workspace }} | ||
steps: | ||
- name: Install prerequisites | ||
env: | ||
YQ_VERSION: 3.4.0 | ||
run: | | ||
sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -O /usr/bin/yq | ||
sudo chmod +x /usr/bin/yq | ||
sudo mv /usr/bin/yq /usr/local/bin/yq | ||
- name: Checkout openshift-knative/hack | ||
uses: actions/checkout@v3 | ||
with: | ||
path: ./src/github.com/openshift-knative/hack | ||
|
||
- name: Setup Golang | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: ./src/github.com/openshift-knative/hack/go.mod | ||
|
||
- name: Install YAML2JSON | ||
run: go install github.com/bronze1man/yaml2json@latest | ||
|
||
- name: Convert configurations to JSON | ||
working-directory: ./src/github.com/openshift-knative/hack | ||
run: find config/*.yaml | xargs -I{} sh -c "yaml2json < {} > {}.json" | ||
|
||
- name: Checkout openshift/release | ||
uses: actions/checkout@v3 | ||
with: | ||
branch: 'master' | ||
repository: 'openshift/release' | ||
path: ./src/github.com/openshift-knative/hack/openshift/release | ||
|
||
- name: Configure Git user | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "OpenShift Serverless" | ||
- name: Generate CI | ||
working-directory: ./src/github.com/openshift-knative/hack | ||
# Use master, see https://github.com/peter-evans/create-pull-request/issues/2108 | ||
run: make generate-ci-no-clean ARGS=--branch=master | ||
|
||
- name: Create Pull Request | ||
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref_name == 'main' | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ secrets.SERVERLESS_QE_ROBOT }} | ||
path: ./src/github.com/openshift-knative/hack/openshift/release | ||
base: master | ||
branch: sync-serverless-ci | ||
title: "Sync Serverless CI" | ||
commit-message: "Sync Serverless CI" | ||
push-to-fork: serverless-qe/release | ||
delete-branch: true | ||
body: | | ||
Sync Serverless CI using openshift-knative/hack. |
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,70 +1,82 @@ | ||
--- | ||
name: Generate CI config | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- '**' | ||
push: | ||
branches: | ||
- 'main' | ||
schedule: | ||
- cron: "0 6 * * *" # Daily at 06:00. | ||
workflow_dispatch: # Manual workflow trigger | ||
|
||
pull_request: | ||
branches: | ||
- '**' | ||
push: | ||
branches: | ||
- 'main' | ||
schedule: | ||
- cron: "0 6 * * *" # Daily at 06:00. | ||
workflow_dispatch: # Manual workflow trigger | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
jobs: | ||
generate-ci: | ||
name: generate-ci | ||
runs-on: ubuntu-latest | ||
env: | ||
GOPATH: ${{ github.workspace }} | ||
steps: | ||
- name: Install prerequisites | ||
generate-ci: | ||
name: generate-ci | ||
runs-on: ubuntu-latest | ||
env: | ||
YQ_VERSION: 3.4.0 | ||
run: | | ||
sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -O /usr/bin/yq | ||
sudo chmod +x /usr/bin/yq | ||
sudo mv /usr/bin/yq /usr/local/bin/yq | ||
- name: Checkout openshift-knative/hack | ||
uses: actions/checkout@v3 | ||
with: | ||
path: ./src/github.com/openshift-knative/hack | ||
|
||
- name: Setup Golang | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: ./src/github.com/openshift-knative/hack/go.mod | ||
|
||
- name: Checkout openshift/release | ||
uses: actions/checkout@v3 | ||
with: | ||
branch: 'master' | ||
repository: 'openshift/release' | ||
path: ./src/github.com/openshift-knative/hack/openshift/release | ||
|
||
- name: Configure Git user | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "OpenShift Serverless" | ||
- name: Generate CI | ||
working-directory: ./src/github.com/openshift-knative/hack | ||
# Use master, see https://github.com/peter-evans/create-pull-request/issues/2108 | ||
run: make generate-ci-no-clean ARGS=--branch=master | ||
|
||
- name: Create Pull Request | ||
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref_name == 'main' | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ secrets.SERVERLESS_QE_ROBOT }} | ||
path: ./src/github.com/openshift-knative/hack/openshift/release | ||
base: master | ||
branch: sync-serverless-ci | ||
title: "Sync Serverless CI" | ||
commit-message: "Sync Serverless CI" | ||
push-to-fork: serverless-qe/release | ||
delete-branch: true | ||
body: | | ||
Sync Serverless CI using openshift-knative/hack. | ||
GOPATH: ${{ github.workspace }} | ||
steps: | ||
- name: Install prerequisites | ||
env: | ||
YQ_VERSION: 3.4.0 | ||
run: | | ||
sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -O /usr/bin/yq | ||
sudo chmod +x /usr/bin/yq | ||
sudo mv /usr/bin/yq /usr/local/bin/yq | ||
- name: Checkout openshift-knative/hack | ||
uses: actions/checkout@v3 | ||
with: | ||
path: ./src/github.com/openshift-knative/hack | ||
- name: Setup Golang | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: ./src/github.com/openshift-knative/hack/go.mod | ||
- name: Install YAML2JSON | ||
run: go install github.com/bronze1man/yaml2json@latest | ||
- name: Convert configurations to JSON | ||
working-directory: ./src/github.com/openshift-knative/hack | ||
run: find config/*.yaml | xargs -I{} sh -c "yaml2json < {} > {}.json" | ||
- name: Checkout openshift/release | ||
uses: actions/checkout@v3 | ||
with: | ||
branch: 'master' | ||
repository: 'openshift/release' | ||
path: ./src/github.com/openshift-knative/hack/openshift/release | ||
- name: Configure Git user | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "OpenShift Serverless" | ||
- name: Generate CI | ||
working-directory: ./src/github.com/openshift-knative/hack | ||
# Use master, see https://github.com/peter-evans/create-pull-request/issues/2108 | ||
run: make generate-ci-no-clean ARGS=--branch=master | ||
- name: Create Pull Request | ||
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref_name == 'main' | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ secrets.SERVERLESS_QE_ROBOT }} | ||
path: ./src/github.com/openshift-knative/hack/openshift/release | ||
base: master | ||
branch: sync-serverless-ci | ||
title: "Sync Serverless CI" | ||
commit-message: "Sync Serverless CI" | ||
push-to-fork: serverless-qe/release | ||
delete-branch: true | ||
body: | | ||
Sync Serverless CI using openshift-knative/hack. | ||
- if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref_name == 'main' | ||
name: '[eventing - release-next] Create Konflux PR' | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
base: main | ||
body: '[main] Sync Konflux configurations' | ||
branch: sync-konflux/release-next | ||
commit-message: '[main] Sync Konflux configurations' | ||
delete-branch: true | ||
path: /src/github.com/openshift-knative/hack/openshift-knative/eventing | ||
push-to-fork: serverless-qe/eventing | ||
title: '[main] Sync Konflux configurations' | ||
token: ${{ secrets.SERVERLESS_QE_ROBOT }} |
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 |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
|
||
/openshift | ||
/openshift-knative | ||
/konflux-gen/out | ||
|
||
# MacOS | ||
.DS_Store |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Konflux Gen | ||
|
||
A CLI to get started | ||
using [Konflux](https://redhat-appstudio.github.io/docs.appstudio.io/Documentation/main/). | ||
|
||
## Usage | ||
|
||
### Generate applications and components | ||
|
||
```shell | ||
# Clone openshift/release repository in openshift-release | ||
git clone [email protected]:openshift/release.git openshift-release | ||
konflux-gen --openshift-release-path openshift-release --includes "ci-operator/config/<org>/.*.yaml" --output "$(pwd)/<org>" | ||
``` | ||
|
||
Example command: | ||
|
||
```shell | ||
go run ./cmd/konflux-gen/main.go --openshift-release-path openshift-release \ | ||
--application-name "serverless-operator release-1.32" \ | ||
--includes "ci-operator/config/openshift-knative/.*v1.11.*.yaml" \ | ||
--includes "ci-operator/config/openshift-knative/serverless-operator/.*1.32.*.yaml" \ | ||
--exclude-images ".*source.*" \ | ||
--exclude-images ".*test.*" \ | ||
--output konflux-gen/out | ||
``` |
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,47 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
"github.com/spf13/pflag" | ||
|
||
"github.com/openshift-knative/hack/pkg/konfluxgen" | ||
) | ||
|
||
const ( | ||
openShiftReleasePathFlag = "openshift-release-path" | ||
applicationNameFlag = "application-name" | ||
includesFlag = "includes" | ||
excludesFlag = "excludes" | ||
excludeImagesFlag = "exclude-images" | ||
outputFlag = "output" | ||
) | ||
|
||
func main() { | ||
if err := run(); err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
func run() error { | ||
|
||
cfg := konfluxgen.Config{} | ||
|
||
pflag.StringVar(&cfg.OpenShiftReleasePath, openShiftReleasePathFlag, "", "openshift/release repository path") | ||
pflag.StringVar(&cfg.ApplicationName, applicationNameFlag, "", "Konflux application name") | ||
pflag.StringVar(&cfg.ResourcesOutputPath, outputFlag, "", "output path") | ||
pflag.StringArrayVar(&cfg.Includes, includesFlag, nil, "Regex to select CI config files to include") | ||
pflag.StringArrayVar(&cfg.Excludes, excludesFlag, nil, "Regex to select CI config files to exclude") | ||
pflag.StringArrayVar(&cfg.ExcludesImages, excludeImagesFlag, nil, "Regex to select CI config images to exclude") | ||
pflag.Parse() | ||
|
||
if cfg.OpenShiftReleasePath == "" { | ||
return fmt.Errorf("expected %q flag to be non empty", openShiftReleasePathFlag) | ||
} | ||
if len(cfg.Includes) == 0 { | ||
return fmt.Errorf("expected %q flag to be non empty", includesFlag) | ||
} | ||
|
||
return konfluxgen.Generate(cfg) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"log" | ||
"path/filepath" | ||
|
||
"github.com/openshift-knative/hack/pkg/action" | ||
) | ||
|
||
func main() { | ||
|
||
inputConfig := flag.String("config", filepath.Join("config"), "Specify repositories config") | ||
inputAction := flag.String("input", filepath.Join(".github", "workflows", "release-generate-ci-template.yaml"), "Input action (template)") | ||
outputAction := flag.String("output", filepath.Join(".github", "workflows", "release-generate-ci.yaml"), "Output action") | ||
flag.Parse() | ||
|
||
err := action.UpdateAction(action.Config{ | ||
InputAction: *inputAction, | ||
InputConfigPath: *inputConfig, | ||
OutputAction: *outputAction, | ||
}) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
Oops, something went wrong.