Skip to content

Commit da1c969

Browse files
committed
gh actions refacto
1 parent d226b6e commit da1c969

File tree

3 files changed

+157
-63
lines changed

3 files changed

+157
-63
lines changed

.github/workflows/ci-validation.yml

Lines changed: 16 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -32,71 +32,24 @@ jobs:
3232
buildBroadCastJs:
3333
runs-on: ubuntu-latest
3434
steps:
35-
- uses: actions/checkout@v4
36-
- name: Install dependencies
37-
run: npm ci
38-
working-directory: ${{ env.broadcastjsWorkingDirectory }}
39-
- name: build
40-
run: npm run build
41-
working-directory: ${{ env.broadcastjsWorkingDirectory }}
42-
- name: Run tests
43-
run: npm run test:ci
44-
working-directory: ${{ env.broadcastjsWorkingDirectory }}
45-
- name: Publish Test Report
46-
uses: phoenix-actions/test-reporting@v8
47-
id: test-report # Set ID reference for step
48-
if: ${{ (success() || failure()) && (github.event_name == 'pull_request') }} # run this step even if previous step failed
49-
with:
50-
name: JEST Tests # Name of the check run which will be created
51-
path: ${{ env.broadcastjsWorkingDirectory }}/*-junit.xml # Path to test results
52-
reporter: jest-junit # Format of test results
53-
- name: Publish Tests Results to CodeCov
54-
uses: codecov/test-results-action@v1
55-
with:
56-
fail_ci_if_error: true # optional (default = false)
57-
disable_search: true
58-
files: ./${{ env.broadcastjsWorkingDirectory }}/vitest-junit.xml # optional
59-
flags: broadcast # optional
60-
name: broadcastjs-tests # optional
61-
token: ${{ secrets.CODECOV_TOKEN }} # required
62-
verbose: true # optional (default = false)
63-
- name: Publish Coverage to CodeCov
64-
uses: codecov/codecov-action@v5
65-
with:
66-
fail_ci_if_error: true # optional (default = false)
67-
disable_search: true
68-
files: ./${{ env.broadcastjsWorkingDirectory }}/coverage/lcov.info # optional
69-
flags: broadcast # optional
70-
name: broadcastjs-coverage # optional
71-
token: ${{ secrets.CODECOV_TOKEN }}
72-
verbose: true # optional (default = false)
73-
- name: Create destination folder
74-
run: mkdir -p ${{env.artifactlocation}}
75-
- name: Copy file outputjs into staging directory
76-
run: cp ${{ env.broadcastjsWorkingDirectory }}/dist/broadcast.js ${{env.artifactlocation}}
77-
- name: Upload broadcastjs artifact
78-
if: ${{ success() && (github.event_name == 'push') }}
79-
uses: actions/upload-artifact@v4
80-
with:
81-
name: broadcastjs
82-
path: ${{env.artifactlocation}}
35+
- uses: actions/checkout@v4
36+
- uses: ./github/workflows/templates/buildjs.yml
37+
with:
38+
projectdirectory: ${{ env.broadcastjsWorkingDirectory }}
39+
componentName: broadcastjs
40+
publishArtifact: false
41+
testCommand: 'test:ci'
42+
publishCodeCov: ${{github.event_name == 'pull_request'}}
43+
artifactlocation: ${{env.artifactlocation}}
44+
secrets:
45+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
46+
8347
buildAppModulePickerPCF:
8448
runs-on: ubuntu-latest
8549
steps:
8650
- uses: actions/checkout@v4
87-
- name: Install dependencies
88-
run: npm ci
89-
working-directory: ${{ env.pcfWorkkingDirectory }}
90-
- name: build
91-
run: npm run build
92-
working-directory: ${{ env.pcfWorkkingDirectory }}
93-
- name: Create destination folder
94-
run: mkdir -p ${{env.artifactlocation}}
95-
- name: Copy file output pcf bundle into staging directory
96-
run: cp ${{ env.pcfWorkkingDirectory }}/out/controls/AppModulePicker/* ${{env.artifactlocation}}
97-
- name: Upload AppModulePicker artifact
98-
if: ${{ success() && (github.event_name == 'push') }}
99-
uses: actions/upload-artifact@v4
51+
- uses: ./.github/workflows/templates/buildpcf.yml
10052
with:
101-
name: AppModulePicker
102-
path: ${{env.artifactlocation}}
53+
pcfdirectory: ${{ env.pcfWorkkingDirectory }}
54+
publishArtifact: false
55+
componentName: AppModulePicker
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# This workflow will build a .NET project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
3+
4+
name: buildjs
5+
on:
6+
workflow_call:
7+
inputs:
8+
projectdirectory:
9+
required: true
10+
type: string
11+
componentName:
12+
required: true
13+
type: string
14+
publishArtifact:
15+
required: true
16+
type: boolean
17+
testCommand:
18+
required: true
19+
type: string
20+
publishCodeCov:
21+
required: true
22+
type: boolean
23+
artifactlocation:
24+
required: false
25+
type: string
26+
secrets:
27+
CODECOV_TOKEN:
28+
required: false
29+
jobs:
30+
buildJS:
31+
name: Build ${{ inputs.componentName }}
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Install dependencies
35+
run: npm ci
36+
working-directory: ${{ inputs.projectdirectory }}
37+
- name: build
38+
run: npm run build
39+
working-directory: ${{ inputs.projectdirectory }}
40+
- name: Run tests
41+
run: npm run ${{ inputs.testCommand }}
42+
working-directory: ${{ inputs.projectdirectory }}
43+
- name: Publish Test Report
44+
uses: phoenix-actions/test-reporting@v8
45+
id: test-report # Set ID reference for step
46+
if: ${{ (success() || failure()) && inputs.publishCodeCov }} # run this step even if previous step failed
47+
with:
48+
name: JEST Tests # Name of the check run which will be created
49+
path: ${{ inputs.projectdirectory }}/*-junit.xml # Path to test results
50+
reporter: jest-junit # Format of test results
51+
- name: Publish Tests Results to CodeCov
52+
uses: codecov/test-results-action@v1
53+
if: ${{ (success() || failure()) && inputs.publishCodeCov }}
54+
with:
55+
fail_ci_if_error: true # optional (default = false)
56+
disable_search: true
57+
files: ./${{ inputs.projectdirectory }}/vitest-junit.xml # optional
58+
flags: broadcast # optional
59+
name: ${{ inputs.componentName }}-tests # optional
60+
token: ${{ secrets.CODECOV_TOKEN }} # required
61+
verbose: true # optional (default = false)
62+
- name: Publish Coverage to CodeCov
63+
uses: codecov/codecov-action@v5
64+
if: ${{ (success() || failure()) && inputs.publishCodeCov }}
65+
with:
66+
fail_ci_if_error: true # optional (default = false)
67+
disable_search: true
68+
files: ./${{ inputs.projectdirectory }}/coverage/lcov.info # optional
69+
flags: broadcast # optional
70+
name: ${{ inputs.componentName }}-coverage # optional
71+
token: ${{ secrets.CODECOV_TOKEN }}
72+
verbose: true # optional (default = false)
73+
- name: Create destination folder
74+
if: ${{ success() && inputs.publishArtifact }}
75+
run: mkdir -p ${{inputs.artifactlocation}}
76+
- name: Copy file outputjs into staging directory
77+
if: ${{ success() && inputs.publishArtifact }}
78+
run: cp ${{ inputs.projectdirectory }}/dist/broadcast.js ${{inputs.artifactlocation}}
79+
- name: Upload ${{ inputs.componentName }} artifact
80+
if: ${{ success() && inputs.publishArtifact }}
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: ${{ inputs.componentName }}
84+
path: ${{inputs.artifactlocation}}
85+
86+
87+
88+
89+
90+
91+
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# This workflow will build a .NET project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
3+
4+
name: buildPCF
5+
on:
6+
workflow_call:
7+
inputs:
8+
pcfdirectory:
9+
required: true
10+
type: string
11+
publishArtifact:
12+
required: true
13+
type: boolean
14+
componentName:
15+
required: true
16+
type: string
17+
artifactlocation:
18+
required: false
19+
type: string
20+
jobs:
21+
buildPCF:
22+
name: Build ${{ inputs.componentName }}
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Install dependencies
26+
run: npm ci
27+
working-directory: ${{ inputs.pcfdirectory }}
28+
- name: build
29+
run: npm run build
30+
working-directory: ${{ inputs.pcfdirectory }}
31+
- name: Create destination folder
32+
if: ${{ success() && inputs.publishArtifact }}
33+
run: mkdir -p ${{inputs.artifactlocation}}
34+
- name: Copy file output pcf bundle into staging directory
35+
if: ${{ success() && inputs.publishArtifact }}
36+
run: cp ${{ inputs.pcfdirectory }}/out/controls/${{ inputs.componentName }}/* ${{inputs.artifactlocation}}
37+
- name: Upload ${{ inputs.componentName }} artifact
38+
if: ${{ success() && inputs.publishArtifact }}
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: ${{ inputs.componentName }}
42+
path: ${{inputs.artifactlocation}}
43+
44+
45+
46+
47+
48+
49+
50+

0 commit comments

Comments
 (0)