forked from opensearch-project/opensearch-migrations
-
Notifications
You must be signed in to change notification settings - Fork 0
202 lines (181 loc) · 5.46 KB
/
CI.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: CI
on:
push:
pull_request:
jobs:
setup-python:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: pwd
- run: ls -al
python-lint:
needs: setup-python
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
- name: Analysing the code with flake8
run: |
flake8 $(git ls-files '*.py')
console-library-tests:
needs: setup-python
runs-on: ubuntu-latest
defaults:
run:
working-directory: ../TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link
steps:
- run: pwd
- run: ls -al
- name: Install Dependencies for Console Library and Tests
run: |
python -m pip install . -r ./tests/requirements.txt
- name: Run Tests
run: |
python -m coverage run -m pytest
- name: Generate XML Coverage Report
run: |
python -m coverage xml
- name: Upload Coverage Report
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml
flags: python-test
setup-gradle:
runs-on: ubuntu-latest
outputs:
docker-cache-key: ${{ steps.generate_cache_key.outputs.key }}
steps:
- name: Check out code
uses: actions/checkout@v4
- run: pwd
- run: ls -al
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'corretto'
- run: pwd
- run: ls -al
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 8.0.2
gradle-home-cache-cleanup: true
cache-read-only: false
- run: pwd
- run: ls -al
- name: Generate Cache Key from Dockerfiles
id: generate_cache_key
run: |
files=$(find . -type f \( -name 'docker-compose.yml' -o -name 'Dockerfile' \))
file_contents=$(cat $files)
key=$(echo "${file_contents}" | sha1sum | awk '{print $1}')
echo "key=${key}" >> "$GITHUB_OUTPUT"
- run: pwd
- run: ls -al
gradle-tests:
needs: setup-gradle
runs-on: ubuntu-latest
steps:
- run: pwd
- run: ls -al
- name: Run Gradle Build
run: ./gradlew build -x test -x TrafficCapture:dockerSolution:build --scan --stacktrace
env:
OS_MIGRATIONS_GRADLE_SCAN_TOS_AGREE_AND_ENABLED: ''
- name: Run Tests with Coverage
run: ./gradlew test -x TrafficCapture:dockerSolution:build jacocoTestReport --scan --stacktrace
env:
OS_MIGRATIONS_GRADLE_SCAN_TOS_AGREE_AND_ENABLED: ''
- uses: actions/upload-artifact@v4
if: always()
with:
name: traffic-capture-test-reports
path: |
./TrafficCapture*/*/build/reports/
- uses: actions/upload-artifact@v4
if: always()
with:
name: RFS-test-reports
path: |
./RFS*/*/build/reports/
- name: Upload to Codecov
uses: codecov/codecov-action@v4
with:
files: "**/jacocoTestReport.xml"
flags: gradle-test
fail_ci_if_error: false
python-e2e-tests:
needs:
- setup-python
- setup-gradle
runs-on: ubuntu-latest
steps:
- name: Cache Docker Images
uses: ScribeMD/[email protected]
with:
key: docker-${{ runner.os }}-${{ needs.setup-gradle.outputs.docker-cache-key }}
- name: Start Docker Solution
run: ./gradlew -p TrafficCapture dockerSolution:ComposeUp -x test --scan --info --stacktrace
env:
OS_MIGRATIONS_GRADLE_SCAN_TOS_AGREE_AND_ENABLED: ''
- name: Install dependencies
run: |
cd test
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run E2E test script
run: |
cd test
chmod +x ./tests.py
pytest tests.py --unique_id="testindex"
cdk-tests:
strategy:
matrix:
node-version: ['18.x']
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ./deployment/cdk/opensearch-service-migration
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install NPM dependencies
run: npm ci
- name: Run CDK Jest Tests
run: npm test
link-checker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: lychee Link Checker
id: lychee
uses: lycheeverse/lychee-action@v1
with:
args: --verbose --accept=200,403,429 "**/*.html" "**/*.md" "**/*.txt" "**/*.json"
--offline
--exclude "file:///github/workspace/*"
--exclude "http://localhost*"
--exclude "https://localhost*"
--exclude "http://capture-proxy*"
--exclude "https://capture-proxy*"
--exclude-mail
fail: true
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}