-
Notifications
You must be signed in to change notification settings - Fork 47
230 lines (200 loc) · 7.57 KB
/
cross-language-validation.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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
name: 'Cross Language Validation'
on:
workflow_dispatch:
inputs:
go-version:
description: 'Go version'
required: false
java-version:
description: 'Java version'
required: false
pull_request:
branches:
- main
paths:
- '.github/workflows/cross-language-validation.yml'
- 'tests/cross-language/**'
- 'go/**'
- 'java/**'
- 'csharp/**'
- 'server/**'
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-cross-lang-${{ github.ref }}
cancel-in-progress: true
env:
DYNAMODB_HOSTNAME: dynamodb
MYSQL_HOSTNAME: mysql
MYSQL_DATABASE: testdb
MYSQL_USERNAME: root
MYSQL_PASSWORD: Password123
DISABLE_TESTCONTAINERS: true
AWS_ACCESS_KEY_ID: dummykey
AWS_SECRET_ACCESS_KEY: dummy_secret
AWS_DEFAULT_REGION: us-west-2
AWS_REGION: us-west-2
jobs:
init-defaults:
name: Init Defaults
runs-on: ubuntu-latest
outputs:
go-version: ${{ steps.init.outputs.go-version }}
java-version: ${{ steps.init.outputs.java-version }}
steps:
- id: init
name: Init versions
run: |
go_version="${{ inputs.go-version }}"
if [ -z "${go_version}" ]; then
go_version='stable'
fi
echo "Go version: ${go_version}"
echo "go-version=${go_version}" >> $GITHUB_OUTPUT
java_version="${{ inputs.java-version }}"
if [ -z "${java_version}" ]; then
java_version='17'
fi
echo "Java version: ${java_version}"
echo "java-version=${java_version}" >> $GITHUB_OUTPUT
server-samples:
name: 'Server Samples: Build & Test'
runs-on: ubuntu-latest
needs: init-defaults
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Install build tools
run: |
sudo apt-get update
sudo apt-get -y upgrade --fix-missing
sudo apt-get install -y build-essential
- name: Set up Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: ${{ needs.init-defaults.outputs.go-version }}
cache-dependency-path: 'go/*/go.sum'
- name: Set up Java
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: ${{ needs.init-defaults.outputs.java-version }}
distribution: 'temurin'
cache: 'maven'
cache-dependency-path: 'java/*/pom.xml'
- name: Set up Python
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: '3.x'
cache: 'pip'
- name: Set up Node
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: '20.x'
- name: Build the Java project
run: |
mvn -v
# Delete previous builds and rebuild from the current branch
rm -rf ~/.m2/repository/com/godaddy/asherah/grpc-server ~/.m2/repository/com/godaddy/asherah/appencryption
mvn --no-transfer-progress clean install -f java/app-encryption/pom.xml -DskipTests
mvn --no-transfer-progress clean install -f server/java/pom.xml -DskipTests
- name: Test clients
run: |
cd server/samples/clients
./test_clients.sh
cross-language-tests:
name: Cross-Language Tests
runs-on: ubuntu-latest
needs: init-defaults
services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }}
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_PASSWORD }}
ports:
- 3306
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 10
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up C#
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1
with:
dotnet-version: |
3.1.x
6.0.x
- name: Set up Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: ${{ needs.init-defaults.outputs.go-version }}
cache-dependency-path: 'go/*/go.sum'
- name: Set up Java
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: ${{ needs.init-defaults.outputs.java-version }}
distribution: 'temurin'
cache: 'maven'
cache-dependency-path: 'java/*/pom.xml'
- name: Set up Python
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: '3.x'
cache: 'pip'
- name: Initialize RDBMS based metastore
run: |
mysql -h 127.0.0.1 -P${{ job.services.mysql.ports[3306] }} -u ${{ env.MYSQL_USERNAME }} -p${{ env.MYSQL_PASSWORD }} -e "CREATE TABLE ${{ env.MYSQL_DATABASE }}.encryption_key (
id VARCHAR(255) NOT NULL,
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
key_record TEXT NOT NULL,
PRIMARY KEY (id, created),
INDEX (created)
);"
- name: Build the Java project
run: |
mvn -v
# Delete previous builds and rebuild from the current branch
rm -rf ~/.m2/repository/com/godaddy/asherah/grpc-server ~/.m2/repository/com/godaddy/asherah/appencryption
mvn --no-transfer-progress clean install -f java/app-encryption/pom.xml -DskipTests
mvn --no-transfer-progress clean install -f server/java/pom.xml -DskipTests
cd tests/cross-language/java
./scripts/build.sh
- name: Build the C# project
run: |
cd tests/cross-language/csharp
./scripts/clean.sh
# Workaround for https://github.com/SpecFlowOSS/SpecFlow/issues/1912#issue-583000545
export MSBUILDSINGLELOADCONTEXT=1
./scripts/build.sh
- name: Download Go dependencies
run: |
cd tests/cross-language/go
# Workaround for https://github.com/golangci/golangci-lint/issues/825
# Without this, the linter may fail with "ERRO Running error: context loading failed: no go files to analyze"
go mod download
- name: Lint the Go project
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
with:
version: 'v1.60.1'
skip-cache: true
working-directory: 'tests/cross-language/go'
- name: Build the Go project
run: |
cd tests/cross-language/go
go mod edit -replace github.com/godaddy/asherah/go/appencryption=../../../go/appencryption
go install github.com/cucumber/godog/cmd/godog@latest
./scripts/build.sh
- name: Test
env:
TEST_DB_NAME: ${{ env.MYSQL_DATABASE }}
TEST_DB_PASSWORD: ${{ env.MYSQL_PASSWORD }}
TEST_DB_USER: ${{ env.MYSQL_USERNAME }}
TEST_DB_HOSTNAME: localhost
TEST_DB_PORT: ${{ job.services.mysql.ports[3306] }}
ASHERAH_SERVICE_NAME: service
ASHERAH_PRODUCT_NAME: product
ASHERAH_KMS_MODE: static
run: |
export JAVA_AE_VERSION=$(mvn -f java/app-encryption/pom.xml -q -DforceStdout help:evaluate -Dexpression=project.version)
cd tests/cross-language/
./scripts/encrypt_all.sh
./scripts/decrypt_all.sh