-
Notifications
You must be signed in to change notification settings - Fork 6
144 lines (125 loc) · 4.5 KB
/
build-test.yml
File metadata and controls
144 lines (125 loc) · 4.5 KB
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
name: Build and Test
on:
pull_request:
branches: [ main ]
paths-ignore:
- '**.md'
- "web-app/**"
- "functions/**"
- ".github/workflows/web-*.yml"
workflow_call:
inputs:
SKIP_TESTS:
description: The skip test parameter is useful for DEV environment deployments, not advised for QA and PROD.
required: false
type: boolean
default: false
env:
python_version: '3.11'
java_version: '11' # needed by setup-openapi-generator.sh
liquibase_version: '4.33.0'
jobs:
build-test:
runs-on: ubuntu-latest
permissions: write-all
name: Build & Test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set whether to run tests
id: set-should-run-tests
run: |
if [ "$GITHUB_EVENT_NAME" != "workflow_call" ] && [ "$GITHUB_EVENT_NAME" != "workflow_dispatch" ]; then
echo "result=true" >> "$GITHUB_OUTPUT"
elif [[ "$INPUTS_SKIP_TESTS" == "false" ]]; then
echo "result=true" >> "$GITHUB_OUTPUT"
else
echo "result=false" >> "$GITHUB_OUTPUT"
fi
env:
INPUTS_SKIP_TESTS: ${{ inputs.SKIP_TESTS }}
- name: Extract commit hash and version from git
run: ./scripts/extract-hash-and-version.sh
- name: Set up JDK ${{ env.java_version }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.java_version }}
distribution: 'temurin'
- uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}
- name: Docker Compose DB
run: |
docker compose --env-file ./config/.env.local up -d postgres postgres-test
working-directory: ${{ github.workspace }}
- name: Run lint checks
if: ${{ steps.set-should-run-tests.outputs.result == 'true' }}
shell: bash
run: |
scripts/lint-tests.sh
- name: Install Liquibase
env:
LIQUIBASE_VERSION: ${{ env.liquibase_version }}
run: |
curl -sSL https://github.com/liquibase/liquibase/releases/download/v${LIQUIBASE_VERSION}/liquibase-${LIQUIBASE_VERSION}.tar.gz -o liquibase.tar.gz
rm -rf liquibase-dist
mkdir liquibase-dist
tar -xzf liquibase.tar.gz -C liquibase-dist
sudo rm -rf /usr/local/liquibase
sudo mv liquibase-dist /usr/local/liquibase
sudo ln -sf /usr/local/liquibase/liquibase /usr/local/bin/liquibase
liquibase --version
- name: Run Liquibase on Python functions test DB
working-directory: ${{ github.workspace }}/liquibase
run: |
export LIQUIBASE_COMMAND_CHANGELOG_FILE="changelog.xml"
export LIQUIBASE_COMMAND_URL=jdbc:postgresql://localhost:54320/MobilityDatabaseTest
export LIQUIBASE_COMMAND_USERNAME=postgres
export LIQUIBASE_COMMAND_PASSWORD=postgres
liquibase update
- name: Generate DB code
run: |
export USE_TEST_DB=true
scripts/db-gen.sh
- name: Generate API code
run: |
scripts/setup-openapi-generator.sh
scripts/api-gen.sh
- name: Generate Operations API code
run: |
scripts/api-operations-gen.sh
- name: Unit tests - API
if: ${{ steps.set-should-run-tests.outputs.result == 'true' }}
shell: bash
run: |
scripts/api-tests.sh --folder api --html_report
- name: Unit tests - Python Functions
if: ${{ steps.set-should-run-tests.outputs.result == 'true' }}
shell: bash
run: |
scripts/api-tests.sh --folder functions-python --html_report
- name: Upload coverage report
uses: actions/upload-artifact@v4
if: ${{ steps.set-should-run-tests.outputs.result == 'true' }}
with:
name: coverage_report
path: scripts/coverage_reports/
overwrite: true
- name: Upload DB models
uses: actions/upload-artifact@v4
with:
name: database_gen
path: api/src/shared/database_gen/
overwrite: true
- name: Upload API generated code
uses: actions/upload-artifact@v4
with:
name: feeds_gen
path: api/src/feeds_gen/
overwrite: true
- name: Upload Operations API generated code
uses: actions/upload-artifact@v4
with:
name: feeds_operations_gen
path: functions-python/operations_api/src/feeds_gen/
overwrite: true