Skip to content

Commit

Permalink
support os_distro and version for CI job
Browse files Browse the repository at this point in the history
  • Loading branch information
Issacwww committed Mar 12, 2024
1 parent 6608e8d commit ace7127
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 13 deletions.
41 changes: 35 additions & 6 deletions .github/actions/bot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,46 @@ class EchoCommand {
}
}

function parseGoal(args) {
const goalMatch = args.match(/^(test|build)/);
if (goalMatch) {
return goalMatch[0];
}
// "test" goal, which executes all CI stages, is the default when no goal is specified
return "test"
}

function parseArgument(args, key) {
const match = args.match(new RegExp(`${key}=([^\\s]+)`));
if (match) {
return match[1];
}
if (key === "os_distro") {
// default to all variants
return "al2,al2023";
}
// set kubernetes_versions to null, the default value will be loaded via eksctl in ci-manual.yaml
return null;
}

class CICommand {
constructor(uuid, payload, args) {
this.repository_owner = payload.repository.owner.login;
this.repository_name = payload.repository.name;
this.pr_number = payload.issue.number;
this.comment_url = payload.comment.html_url;
this.uuid = uuid;
this.goal = "test";
// "test" goal, which executes all CI stages, is the default when no goal is specified
if (args != null && args != "") {
this.goal = args;
}
this.goal = null;
this.os_distro = null;
this.kubernetes_versions = null;
this.goal_args = {};
if (args != null && args !== "") {
console.log(`getting args: ${args}`)
this.goal = parseGoal(args)
this.os_distro = parseArgument(args, "os_distro")
this.kubernetes_versions = parseArgument(args, "k8s_versions")
console.log(`after parsing, goal=${this.goal}, os_distro=${this.os_distro}, kubernetes_versions=${this.kubernetes_versions}`)
}
}

addNamedArguments(goal, args) {
Expand Down Expand Up @@ -188,7 +215,9 @@ class CICommand {
git_sha: pr.data.merge_commit_sha,
goal: this.goal,
requester: author,
comment_url: this.comment_url
comment_url: this.comment_url,
os_distro: this.os_distro,
kubernetes_versions: this.kubernetes_versions
};
for (const [goal, args] of Object.entries(this.goal_args)) {
inputs[`${goal}_arguments`] = args;
Expand Down
22 changes: 18 additions & 4 deletions .github/workflows/ci-manual.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,18 @@ on:
options:
- "build"
- "test"
os_distro:
description: 'Operating System Distributions (comma-separated, e.g., al2,al2023)'
required: false
type: string
kubernetes_versions:
description: 'Kubernetes Versions (comma-separated, e.g., 1.21,1.22)'
required: false
type: string
build_arguments:
required: false
type: string

jobs:
setup:
runs-on: ubuntu-latest
Expand All @@ -42,12 +51,17 @@ jobs:
run: |
echo "git_sha_short=$(echo ${{ inputs.git_sha }} | rev | cut -c-7 | rev)" >> $GITHUB_OUTPUT
echo "workflow_run_url=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_OUTPUT
echo "build_id=ci-${{ inputs.pr_number }}-${{ needs.setup.outputs.git_sha_short }}-${{ inputs.uuid }}" >> $GITHUB_OUTPUT
echo 'ci_step_name_prefix=CI:' >> $GITHUB_OUTPUT
# grab supported versions directly from eksctl
wget --no-verbose -O eksctl.tar.gz "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_Linux_amd64.tar.gz"
tar xzf eksctl.tar.gz && chmod +x ./eksctl
echo "kubernetes_versions=$(./eksctl version --output json | jq -c .EKSServerSupportedVersions)" >> $GITHUB_OUTPUT
echo "build_id=ci-${{ inputs.pr_number }}-${{ needs.setup.outputs.git_sha_short }}-${{ inputs.uuid }}" >> $GITHUB_OUTPUT
echo 'ci_step_name_prefix=CI:' >> $GITHUB_OUTPUT
VERSIONS=${{ '["' + inputs.kubernetes_versions(',', '","') + '"]' }}
if [ -z "$VERSIONS" ]; then
# Default to all supported versions if none specified
VERSIONS=$(./eksctl version --output json | jq -c .EKSServerSupportedVersions)
fi
echo "kubernetes_versions=$VERSIONS" >> $GITHUB_OUTPUT
notify-start:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -77,7 +91,7 @@ jobs:
fail-fast: false
matrix:
k8s_version: ${{ fromJson(needs.setup.outputs.kubernetes_versions) }}
os_distro: [al2, al2023]
os_distro: ${{ fromJson('["' + input.os_distro.replace(',', '","') + '"]') }}
steps:
- uses: actions/checkout@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dependency-review.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v5
with:
go-version: '1.21.6'
go-version: '1.21.8'
- run: go install github.com/securego/gosec/v2/cmd/gosec@latest
- run: gosec -exclude-generated ./...
working-directory: nodeadm
Expand All @@ -27,7 +27,7 @@ jobs:
- uses: actions/checkout@v3
- uses: golang/govulncheck-action@v1
with:
go-version-input: 1.21.6
go-version-input: 1.21.8
work-dir: ./nodeadm
go-version-file: nodeadm/go.mod
cache: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-dependency.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.21.6'
go-version: '1.21.8'
- uses: actions/checkout@v4
- name: Update Nodeadm Dependencies
id: update_deps
Expand Down

0 comments on commit ace7127

Please sign in to comment.