Skip to content

Commit

Permalink
Merge pull request #145 from SamYuan1990/fixKubeConfigIssue
Browse files Browse the repository at this point in the history
fix for kubeconfig existing issue on kepler model server CI
  • Loading branch information
SamYuan1990 authored Oct 9, 2024
2 parents b8b2739 + e25dcbd commit ff139a9
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ jobs:
uses: ./.github/workflows/yamllint.yml
test:
uses: ./.github/workflows/test.yml
edge:
uses: ./.github/workflows/testEdge.yml
2 changes: 2 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ on: # yamllint disable-line rule:truthy
jobs:
test:
uses: ./.github/workflows/test.yml
edge:
uses: ./.github/workflows/testEdge.yml
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ jobs:
matrix:
include:
- cluster_provider: kind
prometheus_operator_version: v0.12.0
prometheus_operator_version: v0.13.0
PROMETHEUS_ENABLE: false
GRAFANA_ENABLE: false
TEKTON_ENABLE: false
test_name: kind_basic
- cluster_provider: kind
prometheus_operator_version: v0.12.0
prometheus_operator_version: v0.13.0
PROMETHEUS_ENABLE: true
GRAFANA_ENABLE: true
TEKTON_ENABLE: true
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/testEdge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: units-test-edge
on: # yamllint disable-line rule:truthy
workflow_call:

jobs:
test_existing_cluster_with_existing_file:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# set up an existing_file
- name: prepare test case
run: |
echo 1 > /tmp/kubeconfig
# set up k8s cluster
- uses: ./
name: dummy cluster for test
with:
cluster_provider: kind
config_cluster: false
# config cluster
- uses: ./
name: config cluster
with:
cluster_provider: existing
prometheus_enable: true
tekton_enable: true
- name: verify
run: |
./verify.sh cluster
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ You can now consume the action by referencing the main branch
prometheus_enable: true
tekton_enable: true
grafana_enable: true

- name: error handle
if: ${{ failure() }}
run: |
ls /tmp
ls /tmp/kubeconfig
```
| parameters | value | comments |
Expand Down
5 changes: 5 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const core = require('@actions/core');
const shell = require('shelljs');
const fs = require('fs');

function getInputOrDefault(inputName, defaultValue) {
const input = core.getInput(inputName);
Expand Down Expand Up @@ -94,6 +95,10 @@ async function setupcluster() {
let command = parameterExport +` && cd local-dev-cluster && bash -xc './main.sh up'`;
core.info('command going to be executed: ' + command);
executeCommand(command, "fail to setup local-dev-cluster")
if (fs.existsSync('/tmp/kubeconfig')) {
core.info('find exists kubeconfig, overwrite by local-dev-cluster setting');
executeCommand(`mv /tmp/kubeconfig /tmp/kubeconfig_bak`)
}
executeCommand(`mkdir -p /tmp/kubeconfig && cp ./local-dev-cluster/.kube/config /tmp/kubeconfig/`)
}

Expand Down

0 comments on commit ff139a9

Please sign in to comment.