-
-
Notifications
You must be signed in to change notification settings - Fork 532
184 lines (177 loc) · 6.3 KB
/
ci-bats-windows.yaml
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
name: Test Bats Windows
on:
workflow_dispatch:
inputs:
email:
description: 'Email address to receive bats failure notification'
required: true
default: ''
repository_dispatch:
types: [ bats-windows ]
jobs:
get-files:
name: Get file list
runs-on: ubuntu-22.04
outputs:
files: ${{ steps.get_file_list.outputs.files }}
steps:
- uses: actions/checkout@v4
if: ${{ github.event_name == 'repository_dispatch' }}
with:
ref: ${{ github.event.client_payload.ref }}
- uses: actions/checkout@v4
if: ${{ github.event_name == 'workflow_dispatch' }}
- name: Get file list
id: get_file_list
run: |
files=$(ls *.bats)
SAVEIFS=$IFS
IFS=$'\n'
file_arr=($files)
echo "files=${file_arr[@]}" >> $GITHUB_OUTPUT
IFS=$SAVEIFS
working-directory: ./integration-tests/bats
format-files-output:
name: Format files output
runs-on: ubuntu-22.04
needs: get-files
outputs:
files: ${{ steps.format_files.outputs.files }}
steps:
- name: Format
id: format_files
uses: actions/github-script@v7
env:
FILES: ${{ needs.get-files.outputs.files }}
with:
debug: true
github-token: ${{ secrets.REPO_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
script: |
try {
const { FILES } = process.env;
const fileList = FILES.split(" ");
core.setOutput("files", JSON.stringify(fileList));
process.exit(0);
} catch(err) {
console.log("Error:", err);
process.exit(1);
}
test-per-file:
name: Test file
needs: format-files-output
defaults:
run:
shell: bash
runs-on: windows-2019
env:
use_credentials: ${{ secrets.AWS_SECRET_ACCESS_KEY != '' && secrets.AWS_ACCESS_KEY_ID != '' }}
strategy:
matrix:
file: ${{ fromJson(needs.format-files-output.outputs.files) }}
steps:
- name: Conditionally Set ENV VARS for AWS tests
run: |
if [[ $use_credentials == true ]]; then
echo "AWS_SDK_LOAD_CONFIG=1" >> $GITHUB_ENV
echo "AWS_REGION=us-west-2" >> $GITHUB_ENV
echo "DOLT_BATS_AWS_TABLE=dolt-ci-bats-manifests-us-west-2" >> $GITHUB_ENV
echo "DOLT_BATS_AWS_BUCKET=dolt-ci-bats-chunks-us-west-2" >> $GITHUB_ENV
echo "DOLT_BATS_AWS_EXISTING_REPO=aws_remote_bats_tests" >> $GITHUB_ENV
fi
- name: Configure AWS Credentials
if: ${{ env.use_credentials == 'true' }}
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-duration-seconds: 3600
- uses: actions/checkout@v4
if: ${{ github.event_name == 'repository_dispatch' }}
with:
ref: ${{ github.event.client_payload.ref }}
- name: Setup Go 1.x
uses: actions/setup-go@v5
with:
go-version-file: go/go.mod
id: go
- name: Setup Python 3.x
uses: actions/setup-python@v5
with:
python-version: "3.10"
- uses: actions/checkout@v4
if: ${{ github.event_name == 'workflow_dispatch' }}
- uses: actions/setup-node@v4
with:
node-version: ^16
- name: Create CI Bin
run: |
mkdir -p ./.ci_bin
echo "$(pwd)/.ci_bin" >> $GITHUB_PATH
- name: Install Bats Windows
run: |
git clone https://github.com/bats-core/bats-core.git
cd bats-core
./install.sh $HOME
working-directory: ./.ci_bin
- name: Install wslpath
run: |
choco install wget
wget 'https://raw.githubusercontent.com/laurent22/wslpath/master/wslpath'
chmod 755 wslpath
mv wslpath /usr/bin/
cp /c/tools/php/php /usr/bin/
- name: Install Python Deps
run: |
pip install mysql-connector-python
pip install pandas
pip install pyarrow
- name: Install Dolt
working-directory: ./go
run: |
go build -mod=readonly -o ../.ci_bin/dolt ./cmd/dolt/.
go build -mod=readonly -o ../.ci_bin/remotesrv ./utils/remotesrv/.
go build -mod=readonly -o ../.ci_bin/noms ./store/cmd/noms/.
- name: Setup Dolt Config
run: |
dolt config --global --add user.name 'Dolthub Actions'
dolt config --global --add user.email '[email protected]'
- name: Test file
run: bats --tap ${{ matrix.file }}
working-directory: ./integration-tests/bats
env:
IS_WINDOWS: true
WINDOWS_BASE_DIR: "/d/a"
BATS_TEST_RETRIES: "3"
report-bats-failure:
name: Report Bats Windows Failure via Email
needs: test-per-file
runs-on: ubuntu-22.04
if: always() && (needs.test-per-file.result == 'failure')
steps:
- uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Send Email
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: ./.github/actions/ses-email-action
with:
region: us-west-2
version: ${{ github.ref }}
template: 'BatsWindowsFailureTemplate'
toAddresses: '["${{ github.event.inputs.email }}"]'
workflowURL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Send Email
if: ${{ github.event_name == 'repository_dispatch' }}
uses: ./.github/actions/ses-email-action
with:
region: us-west-2
version: ${{ github.event.client_payload.ref }}
template: 'BatsWindowsFailureTemplate'
toAddresses: '["${{ github.event.client_payload.actor_email }}", "[email protected]"]'
workflowURL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}