Skip to content
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
5 changes: 1 addition & 4 deletions .github/workflows/code-linting-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ jobs:
lint-common:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd" # v6.0.2
- uses: "actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1" # v7.0.1
with:
fetch-depth: 0
submodules: "recursive"

- uses: "./tools/yscope-dev-utils/exports/github/actions/install-python"
Expand All @@ -54,8 +53,6 @@ jobs:

- run: "task lint:yml-check"

- run: "task lint:check-helm"

lint-cpp:
needs: "filter-relevant-changes"
if: >-
Expand Down
127 changes: 127 additions & 0 deletions .github/workflows/spider-helm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: "spider-helm"

on:
pull_request:
paths: &monitored_paths
- ".github/workflows/spider-helm.yaml"
- "taskfile.yaml"
- "taskfiles/**"
- "tools/deployment/spider-helm/**"
- "tools/yscope-dev-utils"
push:
paths: *monitored_paths
workflow_dispatch:

permissions: {}

concurrency:
group: "${{github.workflow}}-${{github.ref}}"

# Cancel in-progress jobs for efficiency. Exclude the `main` branch to allow uninterrupted
# publishing of Helm charts.
cancel-in-progress: >-
${{
github.ref != 'refs/heads/main'
&& !startsWith(github.ref, 'refs/heads/spider-huntsman-v')
}}

jobs:
lint:
runs-on: "ubuntu-latest"
Comment thread
20001020ycx marked this conversation as resolved.
steps:
- uses: "actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1" # v7.0.1
with:
submodules: "recursive"

# Fetch all history for all branches; otherwise, `helm lint` would complain about not
# finding the `origin/main` branch.
fetch-depth: 0

- uses: "./tools/yscope-dev-utils/exports/github/actions/install-python"
with:
version: "3.10"

- uses: "./tools/yscope-dev-utils/exports/github/actions/install-go-task"
Comment thread
20001020ycx marked this conversation as resolved.
with:
version: "3.48.0"

- name: "Lint Helm charts"
shell: "bash"
run: "task lint:check-helm"

publish:
# Publish from `main` and `spider-huntsman-vA.B.C` release branches.
if: >-
github.event_name != 'pull_request'
&& (github.ref == 'refs/heads/main'
|| startsWith(github.ref, 'refs/heads/spider-huntsman-v'))
needs: "lint"
Comment thread
20001020ycx marked this conversation as resolved.
runs-on: "ubuntu-latest"
Comment thread
20001020ycx marked this conversation as resolved.
concurrency:
group: "${{github.workflow}}-gh-pages"
cancel-in-progress: false
permissions:
# To push to the `gh-pages` branch.
contents: "write"
steps:
- uses: "actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1" # v7.0.1
with:
persist-credentials: false
submodules: "recursive"
Comment thread
20001020ycx marked this conversation as resolved.

- uses: "./tools/yscope-dev-utils/exports/github/actions/install-go-task"
with:
version: "3.48.0"

- name: "Package Helm chart"
shell: "bash"
run: "task helm:package"

- name: "Checkout branch `gh-pages`"
uses: "actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1" # v7.0.1
with:
path: "gh-pages"
ref: "gh-pages"

- name: "Get chart version"
id: "get-chart-version"
uses: "mikefarah/yq@1b9b4ac5187171d2e5e3129be0cfa827c7f9d53d" # v4.53.3
with:
cmd: "yq '.version' 'tools/deployment/spider-helm/Chart.yaml'"

- name: "Update Helm repository"
id: "update-helm-repo"
shell: "bash"
run: |-
chart_tgz="spider-${{steps.get-chart-version.outputs.result}}.tgz"

# Skip if this chart version already exists.
if [[ -f "gh-pages/${chart_tgz}" ]]; then
echo "Chart ${chart_tgz} already exists, skipping publish."
echo "skip_publish=true" >> "$GITHUB_OUTPUT"
exit 0
fi

cp "build/spider-helm"/*.tgz "gh-pages/"

# Update index.yaml, merging with existing index if present.
. "build/toolchains/helm/env"
url="${{github.server_url}}/${{github.repository}}/raw/gh-pages"
if [[ -f "gh-pages/index.yaml" ]]; then
helm repo index "gh-pages" --merge "gh-pages/index.yaml" --url "${url}"
else
helm repo index "gh-pages" --url "${url}"
fi

- name: "Push to gh-pages branch"
if: "steps.update-helm-repo.outputs.skip_publish != 'true'"
shell: "bash"
working-directory: "gh-pages"
run: |-
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
git add "*.tgz" "index.yaml"
commit_message="ci(helm): Publish spider-${{steps.get-chart-version.outputs.result}}"
commit_message+=" from ${{github.ref_name}} (${{github.sha}})."
git commit -m "$commit_message"
git push
Comment thread
coderabbitai[bot] marked this conversation as resolved.
1 change: 1 addition & 0 deletions taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ includes:
deps: "taskfiles/deps.yaml"
docker: "taskfiles/docker.yaml"
docs: "taskfiles/docs.yaml"
helm: "taskfiles/helm.yaml"
lint: "taskfiles/lint.yaml"
test: "taskfiles/test.yaml"
utils: "tools/yscope-dev-utils/exports/taskfiles/utils/utils.yaml"
Expand Down
19 changes: 19 additions & 0 deletions taskfiles/helm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "3"

includes:
toolchains: "toolchains.yaml"

vars:
G_SPIDER_HELM_BUILD_DIR: "{{.G_BUILD_DIR}}/spider-helm"

tasks:
package:
vars:
OUTPUT_DIR: "{{.G_SPIDER_HELM_BUILD_DIR}}"
deps: ["toolchains:helm"]
cmds:
- "rm -rf '{{.OUTPUT_DIR}}'"
- "mkdir -p '{{.OUTPUT_DIR}}'"
- |-
. "{{.G_HELM_TOOLCHAIN_ENV_FILE}}"
helm package "{{.ROOT_DIR}}/tools/deployment/spider-helm" --destination "{{.OUTPUT_DIR}}"
Loading