forked from AmadeusITGroup/otter
-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (129 loc) · 4.92 KB
/
it-tests.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
131
132
133
134
name: IT Tests
on:
workflow_call:
inputs:
skipNxCache:
type: boolean
default: false
required: false
description: Skip the nx cache
secrets:
NX_CLOUD_ACCESS_TOKEN:
required: false
description: Token to use Nx Cloud token
env:
NX_SKIP_NX_CACHE: ${{ inputs.skipNxCache }}
permissions:
contents: read
jobs:
prepare-verdaccio:
runs-on: ubuntu-latest
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./tools/github-actions/download-build-output
- uses: ./tools/github-actions/setup
- name: Setup verdaccio once for all tests
id: setup-verdaccio
run: |
mkdir ./.verdaccio/storage
chmod a+rwx -R ./.verdaccio/storage
yarn verdaccio:start-persistent
yarn verdaccio:publish
shell: bash
- name: Zip verdaccio storage
run: zip -r verdaccio.zip ./.verdaccio
shell: bash
- name: Publish verdaccio storage
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
with:
name: verdaccio
path: verdaccio.zip
- name: Stop verdaccio
if: always()
run: yarn verdaccio:stop
it-tests:
needs: [prepare-verdaccio]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
packageManager: [yarn, npm]
testEnvironment: [o3r-project-with-app]
runs-on: ${{ matrix.os }}
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
ENFORCED_PACKAGE_MANAGER: ${{ matrix.packageManager }}
PREPARE_TEST_ENV_TYPE: ${{ matrix.testEnvironment }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./tools/github-actions/download-build-output
- uses: ./tools/github-actions/setup
- shell: bash
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
- uses: ./.github/actions/setup-java
with:
install-jdk: 'true'
- name: Get current month to build the cache key
run: echo "currentMonth=$(date +'%Y-%m')" >> $GITHUB_ENV
shell: bash
- name: Cache test-app yarn
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: |
.cache/test-app
!.cache/test-app/cache/@ama-sdk*
!.cache/test-app/cache/@ama-terasu*
!.cache/test-app/cache/@o3r*
!.cache/test-app/npm-cache/_npx/**
key: ${{ runner.os }}-test-app-${{ matrix.packageManager }}-${{ env.currentMonth }}
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
name: Download verdaccio storage prepared in the previous job
with:
name: verdaccio
path: '.'
- name: Setup verdaccio once for all tests
id: setup-verdaccio
run: |
unzip -q -n verdaccio.zip
if [ "$RUNNER_OS" == "Linux" ]; then
chmod a+rwx -R ./.verdaccio/storage
yarn verdaccio:start-persistent
elif [ "$RUNNER_OS" == "Windows" ]; then
npx --yes verdaccio --config $GITHUB_WORKSPACE\\.verdaccio\\conf\\config-without-docker.yaml --listen http://127.0.0.1:4873 &
npx --yes wait-on http://127.0.0.1:4873 -t 180000
fi
shell: bash
- name: Test
id: it-tests
run: yarn test-int
- name: Zip generated app on failure
if: failure() && steps.it-tests.conclusion == 'failure'
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
mkdir -p ./otter
cp -R ./.cache ./otter/.cache
zip -r it-tests.zip ../it-tests ./otter/.cache -x "./otter/.cache/nx/*" -x "../it-tests/*/node_modules/*"
elif [ "$RUNNER_OS" == "Windows" ]; then
tar -acf it-tests.zip -C ../ --exclude="it-tests/*/node_modules/*" it-tests
fi
shell: bash
- name: Publish generated tests environment on failure
if: failure() && steps.it-tests.conclusion == 'failure'
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
with:
name: it-tests-${{ matrix.os }}-${{ matrix.packageManager }}
path: it-tests.zip
- name: Publish tests reports
if: always()
# TODO upgrade to v4 when https://github.com/AmadeusITGroup/otter/issues/1198 is fixed
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: it-reports-${{ matrix.os }}-${{ matrix.packageManager }}
path: 'packages/**/dist-test/it-report.xml'
- name: Stop verdaccio
if: always() && runner.os == 'Linux'
run: yarn verdaccio:stop