-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add unit test to PR workflow to make sure enhancements are back…
…ward compatible. (#27)
- Loading branch information
Showing
6 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: On Pull Request to Main | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
jobs: | ||
validate-changes: | ||
if: '!github.event.pull_request.head.repo.fork' | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
matrix: | ||
include: | ||
- repo_name: quickstart-openshift | ||
params: --set-string global.secrets.databasePassword=test --set-string global.secrets.databaseUser=test --set-string global.secrets.databasePassword=databaseName | ||
- repo_name: pubcode | ||
params: '' | ||
timeout-minutes: 2 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
path: ./helm-service | ||
- uses: actions/checkout@v4 | ||
with: | ||
repository: bcgov/${{ matrix.repo_name }} | ||
ref: main | ||
path: ./${{ matrix.repo_name }} | ||
- name: Add Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
- name: Install Dependencies | ||
run: | | ||
cd ./helm-service/util | ||
npm ci | ||
- name: Execute Program | ||
run: | | ||
DESTINATION_REPO=${{ matrix.repo_name }} node ./helm-service/util/index.js | ||
- name: Validate Changes | ||
shell: bash | ||
run: | | ||
cd ./${{ matrix.repo_name }}/charts/${{ matrix.repo_name }} | ||
helm dependency update | ||
helm template ${{ matrix.repo_name }} --debug ${{ matrix.params }} . | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as fs from "fs"; | ||
import jsYaml from "js-yaml"; | ||
|
||
const fs_promises = fs.promises; | ||
const destination_repo = process.env.DESTINATION_REPO|| "quickstart-openshift"; | ||
const sourceDirectory = "."; | ||
const main = async () => { | ||
const chartYaml = await fs_promises.readFile("./helm-service/charts/component/Chart.yaml"); | ||
const destChartYaml = await fs_promises.readFile(`./${destination_repo}/charts/${destination_repo}/Chart.yaml`); | ||
const chartYamlToJSON =jsYaml.load(chartYaml); | ||
const version = chartYamlToJSON.version; | ||
const destChartYamlToJSON =jsYaml.load(destChartYaml); | ||
const dependencies = destChartYamlToJSON.dependencies; | ||
let newDependencies = []; | ||
for(const element of dependencies){ | ||
if(element.name === 'component'){ | ||
element.version = version; | ||
element.repository = `file://../../../helm-service/charts/component`; | ||
} | ||
newDependencies.push(element); | ||
} | ||
destChartYamlToJSON.dependencies = newDependencies; | ||
const newDestChartYaml = jsYaml.dump(destChartYamlToJSON); | ||
await fs_promises.writeFile(`./${destination_repo}/charts/${destination_repo}/Chart.yaml`, newDestChartYaml); | ||
} | ||
await main(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "util", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"main": "index.js", | ||
"dependencies": { | ||
"js-yaml": "^4.1.0" | ||
} | ||
} |