Skip to content
Open
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
61 changes: 0 additions & 61 deletions .cursor/rules/zz_generated.base-llm-rules.mdc

This file was deleted.

35 changes: 0 additions & 35 deletions .cursor/rules/zz_generated.go-llm-rules.mdc

This file was deleted.

16 changes: 16 additions & 0 deletions .github/workflows/pre_commit_go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,34 @@ on:
push:
branches: [main]

permissions: {}

jobs:
pre-commit:
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- name: Check out code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Python environment
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
- name: Set up Go environment
id: setup-go
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
with:
go-version: "1.27"
cache: false
- name: Cache Go modules, Go builds and golangci-lint
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~/.cache/golangci-lint
key: pre-commit-go-${{ runner.os }}-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
pre-commit-go-${{ runner.os }}-${{ steps.setup-go.outputs.go-version }}-
- name: Install goimports
run: |
go install golang.org/x/tools/cmd/goimports@v0.42.0
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/zz_generated.add-team-labels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
issues:
types: [assigned]

# GITHUB_TOKEN gets no permissions by default. The workflow uses the
# project-automation App's token.
permissions: {}

jobs:
build_user_list:
name: Get yaml config of GS users
Expand All @@ -15,7 +19,7 @@ jobs:
# single-file permission on the two mapping files, nothing else there.
- name: Mint App token for the user mapping
id: app-token
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
with:
client-id: ${{ secrets.PROJECT_AUTOMATION_CLIENT_ID }}
private-key: ${{ secrets.PROJECT_AUTOMATION_PRIVATE_KEY }}
Expand Down Expand Up @@ -66,7 +70,7 @@ jobs:
- name: Mint App token for the label
id: app-token
if: ${{ env.LABEL != '' && env.LABEL != 'null' && env.LABEL != null }}
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
with:
client-id: ${{ secrets.PROJECT_AUTOMATION_CLIENT_ID }}
private-key: ${{ secrets.PROJECT_AUTOMATION_PRIVATE_KEY }}
Expand Down
118 changes: 108 additions & 10 deletions .github/workflows/zz_generated.add-to-project-board.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
- assigned
- labeled

# GITHUB_TOKEN gets no permissions by default. The workflow uses the
# project-automation App's token.
permissions: {}

jobs:
build_user_list:
name: Get yaml config of GS users
Expand All @@ -19,7 +23,7 @@ jobs:
# single-file permission on the two mapping files, nothing else there.
- name: Mint App token for the mappings
id: app-token
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
with:
client-id: ${{ secrets.PROJECT_AUTOMATION_CLIENT_ID }}
private-key: ${{ secrets.PROJECT_AUTOMATION_PRIVATE_KEY }}
Expand Down Expand Up @@ -79,15 +83,15 @@ jobs:
- name: Mint App token for the board
id: app-token
if: ${{ env.BOARD != 'null' && env.BOARD != '' && env.BOARD != null }}
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
with:
client-id: ${{ secrets.PROJECT_AUTOMATION_CLIENT_ID }}
private-key: ${{ secrets.PROJECT_AUTOMATION_PRIVATE_KEY }}
permission-issues: read
permission-organization-projects: write
- name: Add issue to personal board
if: ${{ env.BOARD != 'null' && env.BOARD != '' && env.BOARD != null }}
uses: actions/add-to-project@5afcf98fcd03f1c2f92c3c83f58ae24323cc57fd # v2.0.0
uses: actions/add-to-project@f2c1f1fa649a891be84948ea89b5dfba1526ef05 # v2.0.1
with:
project-url: ${{ env.BOARD }}
github-token: ${{ steps.app-token.outputs.token }}
Expand All @@ -114,39 +118,133 @@ jobs:
- name: Mint App token for the board
id: app-token
if: ${{ env.BOARD != 'null' && env.BOARD != '' && env.BOARD != null }}
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
with:
client-id: ${{ secrets.PROJECT_AUTOMATION_CLIENT_ID }}
private-key: ${{ secrets.PROJECT_AUTOMATION_PRIVATE_KEY }}
permission-issues: read
permission-organization-projects: write
- name: Add issue to team board
id: add-to-board
if: ${{ env.BOARD != 'null' && env.BOARD != '' && env.BOARD != null }}
uses: actions/add-to-project@5afcf98fcd03f1c2f92c3c83f58ae24323cc57fd # v2.0.0
uses: actions/add-to-project@f2c1f1fa649a891be84948ea89b5dfba1526ef05 # v2.0.1
with:
project-url: ${{ env.BOARD }}
github-token: ${{ steps.app-token.outputs.token }}
# The roadmap board's Team field is a single select whose options carry
# emoji ("Honey Badger 🦡"); a label matches the option with the same
# letters, so team/honeybadger and team/honey-badger both match.
- name: Set the roadmap Team field from the team label
if: >-
steps.add-to-board.outputs.itemId != '' &&
env.BOARD == 'https://github.com/orgs/giantswarm/projects/273' &&
startsWith(github.event.label.name, 'team/') &&
github.event.label.name != 'team/null'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
ITEM_ID: ${{ steps.add-to-board.outputs.itemId }}
LABEL: ${{ github.event.label.name }}
run: |
set -euo pipefail
team=$(printf '%s' "${LABEL#team/}" | tr -cd '[:alpha:]' | tr '[:upper:]' '[:lower:]')
read -r project field option < <(gh api graphql -F number=273 -f query='
query($number: Int!) {
organization(login: "giantswarm") {
projectV2(number: $number) {
id
field(name: "Team") { ... on ProjectV2SingleSelectField { id options { id name } } }
}
}
}' | jq -r --arg team "$team" '.data.organization.projectV2 as $p
| ($p.field.options[] | select((.name | ascii_downcase | gsub("[^a-z]"; "")) == $team) | .id) as $o
| [$p.id, $p.field.id, $o] | @tsv') || true
if [ -z "${option:-}" ]; then
echo "::warning::No roadmap Team option matches ${LABEL}"
exit 0
fi
gh api graphql -f project="$project" -f item="$ITEM_ID" -f field="$field" -f option="$option" -f query='
mutation($project: ID!, $item: ID!, $field: ID!, $option: String!) {
updateProjectV2ItemFieldValue(input: {projectId: $project, itemId: $item, fieldId: $field, value: {singleSelectOptionId: $option}}) {
projectV2Item { id }
}
}' > /dev/null
echo "Team set from ${LABEL}"

# The repository's owning team is the single team of the CODEOWNERS default
# rule, which align-files writes from the team file that declares it. Its
# label, added as the App, fires `labeled`, and add_to_team_board puts the
# issue on the team's board. An issue opened with a team label keeps it.
add_owner_team_label:
name: Add the owning team's label to a new issue
runs-on: ubuntu-latest
if: >-
github.event.action == 'opened' &&
!contains(join(github.event.issue.labels.*.name, ' '), 'team/')
permissions:
contents: read
outputs:
team: ${{ steps.owner.outputs.team }}
steps:
- name: Find the owning team in CODEOWNERS
id: owner
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
codeowners=""
for path in .github/CODEOWNERS CODEOWNERS docs/CODEOWNERS; do
if codeowners=$(gh api -H "Accept: application/vnd.github.raw" "repos/${GITHUB_REPOSITORY}/contents/${path}" 2>/dev/null); then
break
fi
codeowners=""
done
# The last matching rule wins, as GitHub reads CODEOWNERS.
rule=$(printf '%s\n' "$codeowners" | sed 's/#.*//' | awk '$1 == "*"' | tail -n 1)
teams=$(printf '%s\n' "$rule" | grep -oE '@giantswarm/team-[a-z0-9-]+' | sed 's|@giantswarm/team-||' | sort -u || true)
if [ "$(printf '%s' "$teams" | grep -c .)" = 1 ]; then
echo "Owning team: ${teams}"
echo "team=${teams}" >> "$GITHUB_OUTPUT"
else
echo "No single owning team in CODEOWNERS"
fi
- name: Mint App token for the label
id: app-token
if: steps.owner.outputs.team != ''
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
with:
client-id: ${{ secrets.PROJECT_AUTOMATION_CLIENT_ID }}
private-key: ${{ secrets.PROJECT_AUTOMATION_PRIVATE_KEY }}
permission-issues: write
- name: Apply the owning team's label
if: steps.owner.outputs.team != ''
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
LABEL: team/${{ steps.owner.outputs.team }}
ISSUE: ${{ github.event.issue.number }}
run: gh api "repos/${GITHUB_REPOSITORY}/issues/${ISSUE}/labels" -f "labels[]=${LABEL}" > /dev/null

# An issue opened with a label or an assignee also fires `labeled` or
# `assigned`, which add it above; only a bare one is added here.
# A repository without a single owning team: a bare issue still reaches the
# roadmap board's inbox. An issue opened with a label or an assignee also
# fires `labeled` or `assigned`, which add it above.
add_unlabelled_to_roadmap_board:
name: Add unlabelled, unassigned issue to roadmap board
runs-on: ubuntu-latest
needs: add_owner_team_label
if: >-
github.event.action == 'opened' &&
needs.add_owner_team_label.outputs.team == '' &&
join(github.event.issue.labels.*.name, '') == '' &&
join(github.event.issue.assignees.*.login, '') == ''
steps:
- name: Mint App token for the board
id: app-token
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
with:
client-id: ${{ secrets.PROJECT_AUTOMATION_CLIENT_ID }}
private-key: ${{ secrets.PROJECT_AUTOMATION_PRIVATE_KEY }}
permission-issues: read
permission-organization-projects: write
- name: Add issue to roadmap board
uses: actions/add-to-project@5afcf98fcd03f1c2f92c3c83f58ae24323cc57fd # v2.0.0
uses: actions/add-to-project@f2c1f1fa649a891be84948ea89b5dfba1526ef05 # v2.0.1
with:
project-url: https://github.com/orgs/giantswarm/projects/273
github-token: ${{ steps.app-token.outputs.token }}
Loading
Loading