generated from cloudoperators/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(workflows) renaming after convention and introduced shared workf…
…lows (#74) * new workflows as shared tasks for testing * tests packages * fixed node string from inputs * working workflow to check 3rd party lincenses * rework all ci workflows * move check changes to be triggered * move back all workflows since workflows must be defined at the top level of the .github/workflows/ directory * changed paths to the workflows * fixed pipeline to use output from check-licenses and removed double uses * test communicator * rewording * make detect-changes reusable and add description t all inputs * typos * typo * typo * rename * typo after renaming * remove fake changes in apps and libs * reference shared workflows from main
- Loading branch information
Showing
8 changed files
with
365 additions
and
237 deletions.
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,69 @@ | ||
# Run it locally with act | ||
# 1. Install act: | ||
# `brew install act` | ||
# 2. Create a .secret file with the following content: | ||
# `GITHUB_TOKEN=your_github_token` | ||
# PULL REQUEST | ||
# 1. Create a act_pull_request.json file in case of a pull request with the following content: | ||
# `{"inputs": {"paths": "libs/juno-ui-components apps/exampleapp", "node": "20.x"}}` | ||
# 2. Run the following command: | ||
# `act workflow_call --container-architecture linux/amd64 -P default=catthehacker/ubuntu:act-latest -e act_workflow_call_ci.json -W .github/workflows/check-changes-npm-package.yaml` | ||
|
||
name: Detect Changes on the given Paths | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
paths: | ||
description: "Space separated list of paths to be checked for changes" | ||
required: true | ||
type: string | ||
outputs: | ||
changes: | ||
description: "List of found changes in the paths" | ||
value: ${{ jobs.detect-changes.outputs.changes }} | ||
|
||
jobs: | ||
detect-changes: | ||
runs-on: [default] | ||
outputs: | ||
changes: ${{ steps.package-filters.outputs.changes}} | ||
steps: | ||
- name: Print Inputs | ||
run: | | ||
echo "====${{ github.workflow }} Inputs====" | ||
echo "Inputs: ${{ toJson(inputs) }}" | ||
echo "====" | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Generate filters | ||
id: generate-filters | ||
run: | | ||
# Split the input string by spaces into an array | ||
IFS=' ' read -r -a paths <<< "${{ inputs.paths }}" | ||
# Create a filter for each folder/package in the paths | ||
echo "" > package_filters.yaml | ||
for path in "${paths[@]}"; do | ||
for folder in $path/*; do | ||
echo "$folder: $folder/**" >> package_filters.yaml | ||
done | ||
done | ||
- name: Set specific filters for the packages wihtin the paths | ||
uses: dorny/paths-filter@v3 | ||
id: package-filters | ||
with: | ||
list-files: json | ||
filters: package_filters.yaml | ||
|
||
- name: Show outputs | ||
run: | | ||
echo "===${{ github.workflow }} Outputs===" | ||
echo "====Package filters====" | ||
cat package_filters.yaml | ||
echo "========" | ||
echo changed packages: ${{ steps.package-filters.outputs.changes}} | ||
echo "====================" |
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,82 @@ | ||
# Run it locally with act | ||
# 1. Install act: | ||
# `brew install act` | ||
# 2. Create a .secret file with the following content: | ||
# `GITHUB_TOKEN=your_github_token` | ||
# WORKFLOW CALL | ||
# 1.Create a act_workflow_call.json file with the following content: | ||
# `{"inputs": {"path": "packages/juno-ui-components", "node": "20.x"}}` | ||
# 2. Run the following command: | ||
# `act workflow_call --eventpath act_workflow_call_check_licenses.json --container-architecture linux/amd64 -P default=catthehacker/ubuntu:act-latest -j check-allowed-3rd-party-licenses` | ||
|
||
name: Check 3rd Party Licenses | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
path: | ||
description: "Path to the npm package" | ||
required: true | ||
type: string | ||
node: | ||
description: "Node version to use" | ||
required: true | ||
type: string | ||
outputs: | ||
contains-self-hosted-registry: | ||
description: "Set to true if the package contains dependencies to our self hosted registry" | ||
value: ${{ jobs.check-allowed-3rd-party-licenses.outputs.contains-self-hosted-registry }} | ||
|
||
jobs: | ||
check-allowed-3rd-party-licenses: | ||
runs-on: [default] | ||
outputs: | ||
contains-self-hosted-registry: ${{ steps.remove-self-hosted-registry.outputs.contains-self-hosted-registry }} | ||
steps: | ||
- name: Print inputs | ||
run: | | ||
echo "====Check licenses Workflow Inputs====" | ||
echo "Inputs: ${{ toJson(inputs) }}" | ||
echo "====" | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ inputs.node }} | ||
|
||
- name: Remove all dependencies to our self hosted registry (temporary do tue not access from the internet) | ||
id: remove-self-hosted-registry | ||
run: | | ||
echo path: ${{ inputs.path }} | ||
cd "${{ inputs.path }}" | ||
cp package.json original-package.json | ||
jq '(.dependencies // {} | with_entries(select(.value | contains("https://assets.juno.global.cloud.sap") | not))) as $deps | | ||
(.devDependencies // {} | with_entries(select(.value | contains("https://assets.juno.global.cloud.sap") | not))) as $devDeps | | ||
(.peerDependencies // {} | with_entries(select(.value | contains("https://assets.juno.global.cloud.sap") | not))) as $peerDeps | | ||
(if ($deps | length) > 0 then .dependencies = $deps else del(.dependencies) end) | | ||
(if ($devDeps | length) > 0 then .devDependencies = $devDeps else del(.devDependencies) end) | | ||
(if ($peerDeps | length) > 0 then .peerDependencies = $peerDeps else del(.peerDependencies) end)' package.json > temp.json && mv temp.json package.json | ||
if diff original-package.json package.json > /dev/null; then | ||
echo "=== No dependencies to our self hosted registry found ===" | ||
echo "contains-self-hosted-registry=false" >> $GITHUB_OUTPUT | ||
else | ||
echo "=== Dependencies to our self hosted registry found ===" | ||
echo "contains-self-hosted-registry=true" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Install npm dependencies and check 3rd party licenses | ||
run: | | ||
echo path: ${{ inputs.path }} | ||
cd "${{ inputs.path }}" | ||
echo "====used package.json to run for license checker====" | ||
cat package.json | ||
echo "========" | ||
npm i | ||
npm install -g license-checker-rseidelsohn | ||
license-checker-rseidelsohn -onlyAllow "MIT;ISC;Apache-2.0;BSD-2-Clause;BSD-3-Clause;BSD-4-Clause;CC-BY-3.0;CC-BY-4.0;BlueOak-1.0.0;CC0-1.0;0BSD;Python-2.0;BSD*;Unlicense" |
This file was deleted.
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,37 @@ | ||
# Run it locally with act | ||
# 1. Install act: | ||
# `brew install act` | ||
# 2. Create a .secret file with the following content: | ||
# `GITHUB_TOKEN=your_github_token` | ||
# PULL REQUEST | ||
# 1. Create a act_pull_request.json file in case of a pull request with the following content: | ||
# `{"pull_request": {"number": <PR number>, "head": {"ref": "<PR branch name>", "sha": "PR commit sha"}, "base": {"ref": "main"}}, "repository": {"name": "juno", "owner": {"login": "cloudoperators"}}}` | ||
# 2. Run the following command: | ||
# `act pull_request --container-architecture linux/amd64 -P default=catthehacker/ubuntu:act-latest -j run-pipeline -e act_pull_request.json -W .github/workflows/ci-npm-packages.yaml` | ||
|
||
name: Detect NPM Package Changes and trigger Pipeline | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
paths: | ||
- "apps/**" | ||
- "libs/**" | ||
|
||
jobs: | ||
run-detect-changes: | ||
uses: cloudoperators/juno/.github/workflows/check-changes-npm-package.yaml@main | ||
with: | ||
paths: "apps libs" | ||
|
||
run-pipeline: | ||
needs: [run-detect-changes] | ||
strategy: | ||
matrix: | ||
change: ${{fromJson(needs.run-detect-changes.outputs.changes)}} | ||
node: [20.x] | ||
fail-fast: false # Allow other jobs to continue if one fails | ||
uses: cloudoperators/juno/.github/workflows/pipeline-npm-package.yaml@main | ||
with: | ||
path: ${{ matrix.change }} | ||
node: "${{ matrix.node }}" |
Oops, something went wrong.