Skip to content

Commit 72ba84f

Browse files
committed
[AAE-32905] - Maybe i was too optimistic
1 parent 3aa7270 commit 72ba84f

File tree

4 files changed

+294
-213
lines changed

4 files changed

+294
-213
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
# precedence. When someone opens a pull request that only
1111
# modifies JS files, only @js-owner and not the global
1212
# owner(s) will be requested for a review.
13-
/e2e/ @eromano @cristinaj
13+
/e2e/ @eromano
1414

1515
# The `docs/*` pattern will match files like
1616
# `docs/getting-started.md` but not further nested files like
1717
# `docs/build-app/troubleshooting.md`.
18-
/docs/ @m-hulbert @eromano
18+
/docs/ @eromano
Lines changed: 289 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,289 @@
1+
name: "pull-request-save"
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
dry-run-flag:
7+
description: 'enable dry-run on artifact push'
8+
required: false
9+
type: boolean
10+
default: true
11+
devel:
12+
description: 'devel'
13+
required: false
14+
type: boolean
15+
default: false
16+
cron-run:
17+
description: 'disables jobs which should not run when cron runs e2es'
18+
required: false
19+
type: boolean
20+
default: false
21+
pull_request:
22+
types: [opened, synchronize, reopened]
23+
branches:
24+
- develop
25+
- master
26+
- develop-patch*
27+
- master-patch*
28+
29+
concurrency:
30+
group: ${{ github.workflow }}-${{ github.ref }}
31+
cancel-in-progress: true
32+
33+
env:
34+
BASE_REF: ${{ github.base_ref }}
35+
HEAD_REF: ${{ github.head_ref }}
36+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
37+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
38+
GITHUB_BRANCH: ${{ github.ref_name }}
39+
GH_BUILD_DIR: ${{ github.workspace }}
40+
GH_COMMIT: ${{ github.sha }}
41+
BUILD_ID: ${{ github.run_id }}
42+
GH_RUN_NUMBER: ${{ github.run_attempt }}
43+
GH_BUILD_NUMBER: ${{ github.run_id }}
44+
JOB_ID: ${{ github.run_id }}
45+
LOG_LEVEL: "ERROR"
46+
S3_BUILD_BUCKET_SHORT_NAME: ${{ secrets.S3_BUILD_BUCKET_SHORT_NAME }}
47+
NODE_OPTIONS: "--max-old-space-size=5120"
48+
DOCKER_REPOSITORY_DOMAIN: ${{ secrets.DOCKER_REPOSITORY_DOMAIN }}
49+
DOCKER_REPOSITORY_USER: ${{ secrets.DOCKER_REPOSITORY_USER }}
50+
DOCKER_REPOSITORY_PASSWORD: ${{ secrets.DOCKER_REPOSITORY_PASSWORD }}
51+
DOCKER_REPOSITORY_STORYBOOK: "${{ secrets.DOCKER_REPOSITORY_DOMAIN }}/alfresco/storybook"
52+
REPO_OWNER: "Alfresco"
53+
REPO_NAME: "alfresco-ng2-components"
54+
STORYBOOK_DIR: "./dist/storybook/stories"
55+
BUILT_LIBS_DIR: "./dist/libs"
56+
NODE_MODULES_DIR: "./node_modules"
57+
REDIRECT_URI: /
58+
59+
jobs:
60+
pre-checks:
61+
runs-on: ubuntu-latest
62+
steps:
63+
- name: Checkout repository
64+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
65+
66+
- name: Ensure SHA pinned actions
67+
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@25ed13d0628a1601b4b44048e63cc4328ed03633 # v3.0.22
68+
69+
- name: Check package-lock.json version
70+
run: |
71+
if [[ $(jq '.lockfileVersion == 3' package-lock.json) == "true" ]] ; then
72+
echo "package-lock.json has a correct version"
73+
else
74+
echo "package-lock must be version 3"
75+
exit 1
76+
fi
77+
78+
check-if-pr-is-approved:
79+
runs-on: ubuntu-latest
80+
steps:
81+
- name: Checkout repository
82+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
83+
with:
84+
fetch-depth: 0
85+
86+
- name: Get branch name
87+
uses: Alfresco/alfresco-build-tools/.github/actions/get-branch-name@c1236aee36bb9b35c5972819fcf8a4d07572e6cd # v8.16.0
88+
89+
- name: Save commit message
90+
uses: Alfresco/alfresco-build-tools/.github/actions/get-commit-message@c1236aee36bb9b35c5972819fcf8a4d07572e6cd # v8.16.0
91+
92+
- name: ci:force flag parser
93+
shell: bash
94+
run: |
95+
if [ "${{ github.event_name }}" == "schedule" ] || [ "${{ github.actor }}" == "dependabot[bot]" ]; then
96+
echo -e "\033[32mci:force check can be skipped\033[0m"
97+
skip_check="true"
98+
elif [[ "$COMMIT_MESSAGE" == *"[ci:force]"* ]]; then
99+
echo -e "\033[32m[ci:force] flag detected. No need for approval.\033[0m"
100+
skip_check="true"
101+
fi
102+
103+
- name: Get PR number
104+
if: ${{ github.event_name != 'schedule' && github.event_name != 'workflow_dispatch' }}
105+
uses: kamatama41/get-pr-number-action@0bcaab5752c0b699149e74667c8ce2f764cbb7fa # v0.9.1
106+
id: action
107+
with:
108+
github_token: ${{ secrets.GITHUB_TOKEN }}
109+
110+
- name: show pr number
111+
shell: bash
112+
run: |
113+
echo "PR: ${{ steps.action.outputs.number }}"
114+
115+
- name: check if pr is approved
116+
env:
117+
DEVEL_FLAG: ${{ inputs.devel }}
118+
GH_TOKEN: ${{ github.token }}
119+
skip_check: "false"
120+
run: |
121+
if [ "${{ github.event_name }}" == "schedule" ] || [ "${{ github.actor }}" == "dependabot[bot]" ]; then
122+
echo -e "\033[32mci:force check can be skipped\033[0m"
123+
skip_check="true"
124+
elif [[ "$COMMIT_MESSAGE" == *"[ci:force]"* ]]; then
125+
echo -e "\033[32m[ci:force] flag detected. No need for approval.\033[0m"
126+
skip_check="true"
127+
fi
128+
129+
if [ "${{ github.actor }}" == "dependabot[bot]" ] || [ "${{ github.actor }}" == "alfresco-build" ]; then
130+
echo -e "\033[32mCommit by ${{ github.actor }}. No need for approval.\033[0m"
131+
skip_check="true"
132+
fi
133+
if [ "${{ github.event_name }}" == "schedule" ] || [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
134+
echo -e "\033[32mSchedule event\033[0m"
135+
skip_check="true"
136+
fi
137+
138+
if [[ "$DEVEL_FLAG" == "true" ]]; then
139+
echo -e "\033[32mDevel flag\033[0m"
140+
skip_check="true"
141+
fi
142+
143+
if [ "$skip_check" == "false" ]; then
144+
echo "Checking PR approval"
145+
prNumber=${{ steps.action.outputs.number }}
146+
echo "PR: $prNumber"
147+
checkApproval=$(gh api /repos/$GITHUB_REPOSITORY/pulls/$prNumber/reviews | jq '.[] | select(.state == "APPROVED") | .user.login')
148+
if [[ $checkApproval ]]; then
149+
echo -e "\033[32mPR approved\033[0m"
150+
else
151+
echo -e "\033[31mPR NOT approved\033[0m"
152+
exit 1
153+
fi
154+
fi
155+
156+
setup:
157+
# long timeout required when cache has to be recreated
158+
timeout-minutes: 30
159+
name: "Setup"
160+
runs-on: ubuntu-latest
161+
needs: [check-if-pr-is-approved, pre-checks]
162+
steps:
163+
- name: Checkout repository
164+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
165+
with:
166+
fetch-depth: 0 # Fetch all history for all tags and branches
167+
- uses: ./.github/actions/setup
168+
- name: install
169+
run: |
170+
npm ci
171+
npx nx run js-api:bundle
172+
npx nx run cli:bundle
173+
- uses: ./.github/actions/upload-node-modules-and-artifacts
174+
175+
generate-affected-matrix:
176+
name: "Generate affected matrix"
177+
runs-on: ubuntu-latest
178+
needs: []
179+
outputs:
180+
matrix: ${{ steps.set-matrix.outputs.matrix }}
181+
steps:
182+
- name: Checkout repository
183+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
184+
with:
185+
fetch-depth: 0
186+
- name: Install dependencies
187+
run: npm ci
188+
- name: Generate affected projects matrix
189+
id: set-matrix
190+
run: |
191+
BASE_REF="${{ github.event.pull_request.base.ref }}"
192+
echo "Base ref is $BASE_REF"
193+
AFFECTED=$(npx nx show projects --affected --target=test --base=origin/$BASE_REF --select=projects --plain --exclude=cli,stories,eslint-angular)
194+
echo "Affected projects: $AFFECTED"
195+
MATRIX_JSON=$(echo $AFFECTED | xargs -n1 | jq -R -s -c 'split("\n")[:-1] | map({ "project": . })')
196+
MATRIX_JSON=$(echo "$MATRIX_JSON" | tr -d '\n' | sed 's/"$//')
197+
echo "Matrix JSON: $MATRIX_JSON"
198+
echo "matrix=$MATRIX_JSON" >> $GITHUB_OUTPUT
199+
200+
trigger-unit-tests:
201+
name: "Unit Tests"
202+
runs-on: ubuntu-latest
203+
needs: [generate-affected-matrix]
204+
steps:
205+
- name: Call unit tests workflow
206+
uses: ./.github/workflows/unit-test-workflow.yml@main
207+
with:
208+
matrix: ${{ needs.generate-affected-matrix.outputs.matrix }}
209+
210+
lint:
211+
# long timeout required when cache has to be recreated
212+
timeout-minutes: 30
213+
name: "Lint"
214+
runs-on: ubuntu-latest
215+
needs: [setup]
216+
steps:
217+
- name: Checkout repository
218+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
219+
with:
220+
fetch-depth: 0 # Fetch all history for all tags and branches
221+
- uses: ./.github/actions/setup
222+
- run: npx nx affected --target=lint $NX_CALCULATION_FLAGS
223+
224+
build-libs:
225+
# long timeout required when cache has to be recreated
226+
timeout-minutes: 30
227+
name: "Build libs"
228+
runs-on: ubuntu-latest
229+
needs: [setup]
230+
steps:
231+
- name: Checkout repository
232+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
233+
with:
234+
fetch-depth: 0 # Fetch all history for all tags and branches
235+
- uses: ./.github/actions/setup
236+
- uses: ./.github/actions/download-node-modules-and-artifacts
237+
- run: NX_REJECT_UNKNOWN_LOCAL_CACHE=0 npx nx affected:build $NX_CALCULATION_FLAGS --prod
238+
- run: NX_REJECT_UNKNOWN_LOCAL_CACHE=0 npx nx affected --target=build-storybook $NX_CALCULATION_FLAGS --configuration=ci
239+
- uses: ./.github/actions/upload-node-modules-and-artifacts
240+
241+
PR-forbidden-labels:
242+
if: ${{ inputs.cron-run == '' || inputs.cron-run == 'false' }}
243+
runs-on: ubuntu-latest
244+
steps:
245+
- id: checkoutRepo
246+
name: Checkout repository
247+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
248+
with:
249+
fetch-depth: 1
250+
- name: PR contains forbidden labels
251+
id: pr-forbidden
252+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
253+
with:
254+
script: |
255+
const issueHasLabels = require('./scripts/github/update/check-issue-has-label.js');
256+
const checkLabels = ['next version ➡️', 'do not merge🙅🏻‍♂️'];
257+
258+
const hasLabel = await issueHasLabels({github, context, checkLabels})
259+
260+
if(hasLabel) {
261+
core.setFailed('The PR contains a forbidden label! You are not allowed to merge until the label is there.');
262+
}
263+
- name: Check value after
264+
run: |
265+
echo "result ${{ toJson(steps.pr-forbidden.*.result) }}" && echo "result ${{ steps.pr-forbidden.*.result }}"
266+
echo "result ${{ contains(toJson(steps.pr-forbidden.*.result), 'failure') }}"
267+
268+
finalize:
269+
if: ${{ always() }}
270+
runs-on: ubuntu-latest
271+
name: Final Results
272+
needs: [check-if-pr-is-approved, pre-checks, setup, trigger-unit-tests, lint, build-libs]
273+
steps:
274+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
275+
- name: identify-slack-group
276+
id: groups
277+
if: ${{ github.event_name == 'schedule' }}
278+
uses: ./.github/actions/slack-group-area
279+
with:
280+
affected: ${{ steps.e2e-result.outputs.result }}
281+
- name: workflow failure
282+
run: exit 1
283+
if: ${{ contains(needs.*.result, 'failure') }}
284+
- name: workflow canceled
285+
run: exit 1
286+
if: ${{ contains(needs.*.result, 'cancelled') }}
287+
- name: workflow success
288+
run: exit 0
289+
if: ${{ contains(needs.*.result, 'success') }}

0 commit comments

Comments
 (0)