Github action for custom metric tests with WPT API #17
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: [pull_request] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
name: WebPageTest Test Cases | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Install dependencies | |
run: npm install webpagetest && npm install jest | |
- name: Run WebPageTest | |
# continue-on-error: true | |
run: | | |
EXPECTED_TESTS=$(for file in $(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} \ | |
${{ github.event.pull_request.head.sha }} | grep -E "^dist/.*\.js$"); do basename "$file"; done | cut -d\. -f1 | sort | uniq) | |
CUSTOM_METRIC_FILES=("00_reset", "a11y" "almanac" "aurora" "cms" "css-variables" "css" \ | |
"ecommerce" "example" "fugu-apis" "javascript" "markup" "media" "observers" "origin-trials" \ | |
"parsed_css" "performance" "privacy" "pwa" "responsive_images" "robots_meta" "robots_txt" \ | |
"sass" "security" "structured-data" "third-parties" "valid-head" "well-known" "wpt_bodies") | |
for TEST in ${EXPECTED_TESTS[@]}; do | |
for CM_FILE in "${CUSTOM_METRIC_FILES[@]}"; do | |
if [[ $TEST == $CM_FILE ]]; then | |
echo "Running test: $TEST" | |
if [ -f "dist/$TEST.test.js" ]; then | |
npm test $TEST | |
else | |
echo "There are no test cases for $TEST" | |
exit 2 | |
fi | |
fi | |
done | |
done | |
env: | |
WPT_API_KEY: ${{ secrets.WPT_API_KEY }} |