-
Notifications
You must be signed in to change notification settings - Fork 2
132 lines (118 loc) · 4.71 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
name: CI
on: [push, pull_request]
jobs:
tests:
runs-on: windows-latest
timeout-minutes: 10
steps:
# Checkout
- name: Checkout
uses: actions/checkout@v3
# The whole Node.js and pnpm installation and caching
# Based on https://github.com/pnpm/action-setup/tree/6e1964dde3397a825e79e4607ad57f3f7ca2c7cb#use-cache-to-reduce-installation-time
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- uses: pnpm/action-setup@v2.0.1
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
# Run basic Svelte checks
- name: Svelte Check
run: npm run check
# Build Frontend
- name: Build Frontend
id: build
if: success() || failure() # Run even if previous failed
run: npm run build
# Setup Nuget and install IE11&Edge web drivers
- name: Setup NuGet.exe
uses: nuget/setup-nuget@v1
- name: Install IE11 Web Driver
run: nuget install Selenium.WebDriver.IEDriver -Version 4.5.0
- name: Install Edge Web Driver
run: |
$full = (wmic.exe DATAFILE WHERE "NAME='C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe'" GET Version /value).Split("") -join ""
$version = $full.Substring($full.indexOf("=") + 1)
echo "Current Edge Version: $version"
$destination = "edge-driver.zip"
Invoke-RestMethod -Uri https://msedgedriver.azureedge.net/$version/edgedriver_win64.zip -OutFile $destination
Expand-Archive $destination -DestinationPath "edge-driver"
- name: Selenium Tests on IE11 and Edge
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
run: |
npm run preview -- --host &
$Env:PATH += ";" + $pwd + "\edge-driver" + ";" + $pwd + "\Selenium.WebDriver.IEDriver.4.5.0\driver"
if ($null -eq $env:PERCY_TOKEN) {
$TEST_SELENIUM_COMMAND = "npm run test-selenium"
} else {
$TEST_SELENIUM_COMMAND = "npx percy exec -- npm run test-selenium"
}
$Env:BROWSER = "ie"
npm run test-selenium
if(!$?) { $HAD_FAILED = $true }
$Env:BROWSER = "edge"
Invoke-expression $TEST_SELENIUM_COMMAND
if(!$?) { $HAD_FAILED = $true }
if($HAD_FAILED) {
throw "One or more selenium tests had failed!"
exit 1
}
- name: Check for BrowserStack secret availability
id: browser-stack-secret-check
if: steps.build.outputs.exit_code == 0 # It should run if and only if the build succeed
# perform secret check & put boolean result as an output
shell: bash
env:
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
run: |
if [ $BROWSERSTACK_ACCESS_KEY != '' ]; then
echo "available=true" >> $GITHUB_OUTPUT;
else
echo "available=false" >> $GITHUB_OUTPUT;
fi
- name: 'BrowserStack Env Setup'
uses: 'browserstack/github-actions/setup-env@master'
if: steps.browser-stack-secret-check.outputs.available
with:
username: ${{ secrets.BROWSERSTACK_USERNAME }}
access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
build-name: 'BUILD_INFO'
project-name: 'SvelteKit Legacy Demo'
- name: 'Start BrowserStackLocal Tunnel'
uses: 'browserstack/github-actions/setup-local@master'
if: steps.browser-stack-secret-check.outputs.available
with:
local-testing: 'start'
local-logging-level: 'all-logs'
local-identifier: 'random'
- name: Selenium Tests on BrowserStack
if: steps.browser-stack-secret-check.outputs.available
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
run: |
npm run preview -- --host &
$Env:BROWSER = "browser-stack"
npm run test-selenium
- name: 'Stop BrowserStackLocal'
uses: 'browserstack/github-actions/setup-local@master'
if: steps.browser-stack-secret-check.outputs.available
with:
local-testing: 'stop'