Skip to content

Commit

Permalink
Add boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinBisson committed Mar 27, 2024
1 parent 04485dc commit 57878ac
Show file tree
Hide file tree
Showing 70 changed files with 1,551 additions and 2,560 deletions.
6 changes: 6 additions & 0 deletions .abs/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
chart-dir: helm/observability-operator
replace-chart-version-with-git: true
replace-app-version-with-git: true
generate-metadata: true
destination: ./build
catalog-base-url: https://giantswarm.github.io/giantswarm-catalog/
86 changes: 55 additions & 31 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,68 +1,92 @@
version: 2.1

orbs:
architect: giantswarm/architect@4.24.0
architect: giantswarm/architect@5.1.1

workflows:
build:
jobs:
- architect/go-build:
name: go-build
binary: template-operator
binary: observability-operator
filters:
tags:
only: /^v.*/

- architect/push-to-docker:
context: "architect"
name: push-template-operator-to-docker
image: "docker.io/giantswarm/template-operator"
username_envar: "DOCKER_USERNAME"
password_envar: "DOCKER_PASSWORD"
- architect/push-to-registries:
context: architect
name: push-to-registries
requires:
- go-build
# Needed to trigger job also on git tag.
filters:
tags:
only: /^v.*/

- architect/push-to-docker:
- architect/push-to-app-catalog:
context: "architect"
name: push-template-operator-to-quay
image: "quay.io/giantswarm/template-operator"
username_envar: "QUAY_USERNAME"
password_envar: "QUAY_PASSWORD"
executor: "app-build-suite"
name: push-to-app-catalog
app_catalog: "control-plane-catalog"
app_catalog_test: "control-plane-test-catalog"
chart: "observability-operator"
requires:
- go-build
# Needed to trigger job also on git tag.
- push-to-registries
filters:
tags:
only: /^v.*/

- architect/push-to-docker:
- architect/push-to-app-collection:
context: "architect"
name: push-template-operator-to-aliyun
image: "giantswarm-registry.cn-shanghai.cr.aliyuncs.com/giantswarm/template-operator"
username_envar: "ALIYUN_USERNAME"
password_envar: "ALIYUN_PASSWORD"
name: capa-app-collection
app_name: "observability-operator"
app_namespace: "monitoring"
app_collection_repo: "capa-app-collection"
requires:
- go-build
# Needed to trigger job also on git tag.
- push-to-app-catalog
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/

- architect/push-to-app-collection:
context: "architect"
name: capz-app-collection
app_name: "observability-operator"
app_namespace: "monitoring"
app_collection_repo: "capz-app-collection"
requires:
- push-to-app-catalog
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/

- architect/push-to-app-collection:
context: "architect"
name: cloud-director-app-collection
app_name: "observability-operator"
app_namespace: "monitoring"
app_collection_repo: "cloud-director-app-collection"
requires:
- push-to-app-catalog
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/

- architect/push-to-app-catalog:
- architect/push-to-app-collection:
context: "architect"
name: push-template-operator-to-app-catalog
app_catalog: "control-plane-catalog"
app_catalog_test: "control-plane-test-catalog"
chart: "template-operator"
name: vsphere-app-collection
app_name: "observability-operator"
app_namespace: "monitoring"
app_collection_repo: "vsphere-app-collection"
requires:
- push-template-operator-to-docker
- push-template-operator-to-quay
# Needed to trigger job also on git tag.
- push-to-app-catalog
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
# Ignore build and test binaries.
bin/
6 changes: 6 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
### What this PR does / why we need it


### Checklist

- [ ] Update changelog in CHANGELOG.md.
53 changes: 53 additions & 0 deletions .github/workflows/zz_generated.add-team-labels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Add appropriate labels to issue

on:
issues:
types: [assigned]

jobs:
build_user_list:
name: Get yaml config of GS users
runs-on: ubuntu-latest
steps:
- name: Get user-mapping
run: |
mkdir -p artifacts
wget --header "Authorization: token ${{ secrets.ISSUE_AUTOMATION }}" \
-O artifacts/users.yaml \
https://raw.githubusercontent.com/giantswarm/github/main/tools/issue-automation/user-mapping.yaml
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: users
path: artifacts/users.yaml
retention-days: 1

add_label:
name: Add team label when assigned
runs-on: ubuntu-latest
needs: build_user_list
steps:
- uses: actions/download-artifact@v3
id: download-users
with:
name: users
- name: Find team label based on user names
run: |
event_assignee=$(cat $GITHUB_EVENT_PATH | jq -r .assignee.login | tr '[:upper:]' '[:lower:]')
echo "Issue assigned to: ${event_assignee}"
TEAMS=$(cat ${{steps.download-users.outputs.download-path}}/users.yaml | tr '[:upper:]' '[:lower:]' | yq ".${event_assignee}.teams" -o csv | tr ',' ' ')
echo "LABEL<<EOF" >> $GITHUB_ENV
for team in ${TEAMS}; do
echo "Team: ${team} | Label: team/${team}"
echo "team/${team}" >> $GITHUB_ENV
done
echo "EOF" >> $GITHUB_ENV
- name: Apply label to issue
if: ${{ env.LABEL != '' && env.LABEL != 'null' && env.LABEL != null }}
uses: actions-ecosystem/action-add-labels@v1
with:
github_token: ${{ secrets.ISSUE_AUTOMATION }}
labels: |
${{ env.LABEL }}
89 changes: 89 additions & 0 deletions .github/workflows/zz_generated.add-to-project-board.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Add Issue to Project when assigned

on:
issues:
types:
- assigned
- labeled

jobs:
build_user_list:
name: Get yaml config of GS users
runs-on: ubuntu-latest
steps:
- name: Get user-mapping
run: |
mkdir -p artifacts
wget --header "Authorization: token ${{ secrets.ISSUE_AUTOMATION }}" \
-O artifacts/users.yaml \
https://raw.githubusercontent.com/giantswarm/github/main/tools/issue-automation/user-mapping.yaml
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: users
path: artifacts/users.yaml
retention-days: 1
- name: Get label-mapping
run: |
mkdir -p artifacts
wget --header "Authorization: token ${{ secrets.ISSUE_AUTOMATION }}" \
-O artifacts/labels.yaml \
https://raw.githubusercontent.com/giantswarm/github/main/tools/issue-automation/label-mapping.yaml
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: labels
path: artifacts/labels.yaml
retention-days: 1

add_to_personal_board:
name: Add issue to personal board
runs-on: ubuntu-latest
needs: build_user_list
if: github.event.action == 'assigned'
steps:
- uses: actions/download-artifact@v3
id: download-users
with:
name: users
- name: Find personal board based on user names
run: |
event_assignee=$(cat $GITHUB_EVENT_PATH | jq -r .assignee.login | tr '[:upper:]' '[:lower:]')
echo "Issue assigned to: ${event_assignee}"
BOARD=($(cat ${{steps.download-users.outputs.download-path}}/users.yaml | tr '[:upper:]' '[:lower:]' | yq ".${event_assignee}.personalboard"))
echo "Personal board URL: ${BOARD}"
echo "BOARD=${BOARD}" >> $GITHUB_ENV
- name: Add issue to personal board
if: ${{ env.BOARD != 'null' && env.BOARD != '' && env.BOARD != null }}
uses: actions/add-to-project@main
with:
project-url: ${{ env.BOARD }}
github-token: ${{ secrets.ISSUE_AUTOMATION }}

add_to_team_board:
name: Add issue to team board
runs-on: ubuntu-latest
needs: build_user_list
if: github.event.action == 'labeled'
steps:
- uses: actions/download-artifact@v3
id: download-labels
with:
name: labels
- name: Find team board based on label
run: |
event_label=$(cat $GITHUB_EVENT_PATH | jq -r .label.name | tr '[:upper:]' '[:lower:]')
echo "Issue labelled with: ${event_label}"
BOARD=($(cat ${{steps.download-labels.outputs.download-path}}/labels.yaml | tr '[:upper:]' '[:lower:]' | yq ".[\"${event_label}\"].projectboard"))
echo "Team board URL: ${BOARD}"
echo "BOARD=${BOARD}" >> $GITHUB_ENV
- name: Add issue to team board
if: ${{ env.BOARD != 'null' && env.BOARD != '' && env.BOARD != null }}
uses: actions/add-to-project@main
with:
project-url: ${{ env.BOARD }}
github-token: ${{ secrets.ISSUE_AUTOMATION }}
69 changes: 38 additions & 31 deletions .github/workflows/zz_generated.check_values_schema.yaml
Original file line number Diff line number Diff line change
@@ -1,46 +1,53 @@
# DO NOT EDIT. Generated with:
#
# devctl@5.8.0
# devctl@6.17.1
#
name: 'Check if values schema file has been updated'
on: pull_request
name: 'Values and schema'
on:
pull_request:
branches:
- master
- main
paths:
- 'helm/**/values.yaml' # default helm chart values
- 'helm/**/values.schema.json' # schema
- 'helm/**/ci/ci-values.yaml' # overrides for CI (can contain required entries)

push: {}

jobs:
check:
name: 'Check values.yaml and its schema in PR'
name: 'validate values.yaml against values.schema.json'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v3
- name: 'Check if values.schema.json was updated'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VALUES_FILE_CHANGED="false"
SCHEMA_FILE_CHANGED="false"
echo "Comparing ${GITHUB_BASE_REF}...${GITHUB_HEAD_REF}"
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

changed_files=$(gh api "repos/{owner}/{repo}/compare/${GITHUB_BASE_REF}...${GITHUB_HEAD_REF}" --jq ".files[] | .filename")
if grep -q "values.schema.json" <<< $(git ls-tree -r --name-only ${GITHUB_SHA}); then
- name: Install validator
run: |
wget -q -O ${HOME}/yajsv https://github.com/neilpa/yajsv/releases/download/v1.4.1/yajsv.linux.amd64
chmod +x ${HOME}/yajsv
if grep -q "values.yaml" <<< "${changed_files}" ; then
VALUES_FILE_CHANGED="true"
fi
- name: 'Check if values.yaml is a valid instance of values.schema.json'
run: |
for chart_yaml in helm/*/Chart.yaml; do
helm_dir="${chart_yaml%/Chart.yaml}"
if grep -q "values.schema.json" <<< "${changed_files}" ; then
SCHEMA_FILE_CHANGED="true"
if [ ! -f ${helm_dir}/values.schema.json ]; then
echo "Skipping validation for '${helm_dir}' folder, because 'values.schema.json' does not exist..."
continue
fi
if [ $VALUES_FILE_CHANGED != $SCHEMA_FILE_CHANGED ]; then
echo "FAILED: values.yaml was updated but values.schema.json hasn't been regenerated"
echo "Please refer to this document: https://intranet.giantswarm.io/docs/organizational-structure/teams/cabbage/app-updates/helm-values-schema/"
exit 1
values=${helm_dir}/values.yaml
if [ -f ${helm_dir}/ci/ci-values.yaml ]; then
# merge ci-values.yaml into values.yaml (providing required values)
echo -e "\nMerged values:\n=============="
yq '. *= load("'${helm_dir}'/ci/ci-values.yaml")' ${helm_dir}/values.yaml | tee ${helm_dir}/combined-values.yaml
echo -e "\n==============\n"
values=${helm_dir}/combined-values.yaml
fi
echo "PASSED: values.yaml and values.schema.json both appear to have been updated"
exit 0
fi
echo "INFO: values.schema.json not present in this repo - nothing to do"
${HOME}/yajsv -s ${helm_dir}/values.schema.json ${values}
done
Loading

0 comments on commit 57878ac

Please sign in to comment.