-
Notifications
You must be signed in to change notification settings - Fork 364
147 lines (129 loc) · 4.88 KB
/
Copy pathazureStorageTests.yml
File metadata and controls
147 lines (129 loc) · 4.88 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
145
146
147
name: Azure Storage Tests
on:
push:
branches:
- '**'
paths:
- 'tests/integration/withServerInstance/storage.tests.js'
- 'Common/sources/storage/**'
- 'DocService/sources/routes/static.js'
- '.github/workflows/azureStorageTests.yml'
jobs:
azure-storage-tests:
name: Azure Storage Tests
runs-on: ubuntu-latest
env:
AZURITE_CONTAINER: azurite-${{ github.run_id }}-${{ github.run_attempt }}
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Pre-run cleanup
run: |
docker rm -f "$AZURITE_CONTAINER" 2>/dev/null || true
- name: Setup and start Azurite
run: |
# Detect network and set network arguments
JOB_NET=$(docker inspect -f '{{range $k,$v := .NetworkSettings.Networks}}{{printf "%s\n" $k}}{{end}}' "$(hostname)" 2>/dev/null | head -n1 || true)
if [ -n "$JOB_NET" ]; then
NETWORK_ARGS="--network $JOB_NET"
else
NETWORK_ARGS=""
fi
# Start Azurite container
docker run --name "$AZURITE_CONTAINER" \
$NETWORK_ARGS \
-p 10000:10000 \
-p 10001:10001 \
-p 10002:10002 \
-d mcr.microsoft.com/azure-storage/azurite \
azurite-blob --blobHost 0.0.0.0 --loose
# Set host based on network configuration
if [ -n "$JOB_NET" ]; then
HOST=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$AZURITE_CONTAINER")
else
HOST=127.0.0.1
fi
# Wait for Azurite to be ready
echo "Waiting for Azurite at $HOST:10000..."
for i in $(seq 1 15); do
if curl -sS "http://$HOST:10000/" >/dev/null 2>&1; then
echo "Azurite ready"
break
fi
sleep 1
done
# Verify Azurite is running
if ! curl -sS "http://$HOST:10000/" >/dev/null 2>&1; then
echo "Azurite failed to start"
docker logs "$AZURITE_CONTAINER" || true
exit 1
fi
# Export host for subsequent steps
echo "AZURITE_HOST=$HOST" >> "$GITHUB_ENV"
- name: Caching dependencies
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: |
./npm-shrinkwrap.json
./Common/npm-shrinkwrap.json
./DocService/npm-shrinkwrap.json
- name: Install modules
run: |
npm ci
npm --prefix Common ci
npm --prefix DocService ci
- name: Setup Azure storage environment
run: |
# Create minimal Azure storage configuration
cat > Common/config/local.json << EOF
{
"storage": {
"name": "storage-az",
"region": "",
"endpoint": "http://${AZURITE_HOST:-127.0.0.1}:10000/devstoreaccount1",
"bucketName": "test-container",
"storageFolderName": "files",
"cacheFolderName": "data",
"accessKeyId": "devstoreaccount1",
"secretAccessKey": "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
},
"persistentStorage": {
"storageFolderName": "files/persistent"
},
"commandOptions": {
"az": {
"uploadData": {},
"uploadStream": {},
"download": {},
"syncCopyFromURL": {},
"listBlobsFlat": {
"maxPageSize": 1000
},
"deleteBlob": {}
}
}
}
EOF
echo "Azure storage configuration created"
- name: Create Azure container using Node.js from Common directory
run: |
# Wait a bit more for Azurite to be fully ready
sleep 10
# Run Node.js script from Common directory where Azure dependencies are installed
cd Common
node -e "
(async () => {
const { BlobServiceClient, StorageSharedKeyCredential } = require('@azure/storage-blob');
const endpoint = 'http://' + (process.env.AZURITE_HOST || '127.0.0.1') + ':10000/devstoreaccount1';
const client = new BlobServiceClient(endpoint, new StorageSharedKeyCredential('devstoreaccount1', 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=='));
await client.getContainerClient('test-container').createIfNotExists();
console.log('Azure environment ready');
})().catch(console.error);
"
- name: Run storage tests
run: npm run storage-tests
- name: Final cleanup
if: always()
run: docker rm -f "$AZURITE_CONTAINER" || true