forked from konveyor/tackle2-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (105 loc) · 3.75 KB
/
ci-repo.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: CI (repo level)
on:
push:
branches:
- "main"
- "release-*"
pull_request:
branches:
- "main"
- "release-*"
workflow_dispatch:
workflow_call:
concurrency:
group: ci-repo-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true
jobs:
unit-test-lookup:
runs-on: ubuntu-latest
outputs:
builder-image: ${{ steps.grepBuilder.outputs.builder }}
should-test: ${{ steps.check-changes.outputs.should-test }}
steps:
- uses: actions/checkout@v4
- name: Lookup builder image from the project's Dockerfile
id: grepBuilder
run: |
builder=$(grep 'as builder' Dockerfile | sed -e 's/^FROM \(.*\) as builder$/\1/')
echo "builder=$builder" >> "$GITHUB_OUTPUT"
- name: Did docs and hacks change?
id: docs-and-hacks
uses: tj-actions/changed-files@v44
with:
files: |
docs/**
hack/**
*.md
- name: Check if only docs and hacks changes have been made in a PR
id: check-changes
env:
IS_PR: ${{ !!github.event.pull_request }}
ONLY_DOCS: ${{ steps.docs-and-hacks.outputs.only_modified }}
run: |
SHOULD_TEST=$(
if [[ $IS_PR == true ]] && [[ $ONLY_DOCS == true ]]; then
echo "false"
else
echo "true"
fi
)
echo "is-pr=$IS_PR" >> "$GITHUB_OUTPUT"
echo "changes_only_docs=${ONLY_DOCS:-false}" >> "$GITHUB_OUTPUT"
echo "should-test=$SHOULD_TEST" >> "$GITHUB_OUTPUT"
- name: Summarize findings
env:
ONLY_DOCS: ${{ steps.docs-and-hacks.outputs.only_modified }}
MODIFIED_FILES: ${{ steps.docs-and-hacks.outputs.all_modified_files }}
run: |
cat >> "$GITHUB_STEP_SUMMARY" <<EOF
## Build container
- CI will run on container: \`${{ steps.grepBuilder.outputs.builder }}\`
## Findings
- The action is PR triggered? \`${{ steps.check-changes.outputs.is-pr }}\`
- Changes are only to docs and hacks? \`${{ steps.check-changes.outputs.changes_only_docs }}\`
- Should the unit test run? \`${{ steps.check-changes.outputs.should-test }}\`
EOF
if [[ $ONLY_DOCS == true ]] && [[ -n "$MODIFIED_FILES" ]]; then
echo "## Modified docs and hacks files that do not impact the build" >> "$GITHUB_STEP_SUMMARY"
for file in ${MODIFIED_FILES}; do
echo " - \`$file\`" >> "$GITHUB_STEP_SUMMARY"
done
fi
unit-test:
runs-on: ubuntu-latest
needs: unit-test-lookup
if: ${{ needs.unit-test-lookup.outputs.should-test == 'true' }}
# Use the same container as the Dockerfile's "FROM * as builder"
container: ${{ needs.unit-test-lookup.outputs.builder-image }}
steps:
- uses: actions/checkout@v4
# TODO: Setup a cache for npm so it could install faster
# follow actions/setup-node@v4 techniques
- name: Verify package-lock.json
run: ./scripts/verify_lock.mjs
- name: Install
run: |
npm version
npm clean-install --ignore-scripts
- name: Lint sources
run: npm run lint
- name: Build
run: npm run build
- name: Test
run: npm run test -- --coverage --watchAll=false
- name: Upload to codecov (client)
# if: ${{ github.event.pull_request }}
uses: codecov/codecov-action@v4
with:
flags: client
directory: ./client/coverage
- name: Upload to codecov (server)
# if: ${{ github.event.pull_request }}
uses: codecov/codecov-action@v4
with:
flags: server
directory: ./server/coverage