merge: improved UI test hooks date setter #447
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: Test | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
workflow_dispatch: | |
inputs: | |
runUiTests: | |
description: Run UI tests | |
required: false | |
type: boolean | |
jobs: | |
ui-tests: | |
if: ${{ github.event.inputs.runUiTests }} # see #5495d097 | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Dismiss upgrade dialog if present | |
run: | | |
update_name=$(softwareupdate -l | grep "Title: " | awk -F[:,] '{print $2}' | awk '{$1=$1};1') | |
if [ ! -z "$update_name" ]; then | |
sudo softwareupdate --ignore "$update_name" | |
fi | |
- name: Get current time | |
id: start_time | |
run: 'echo "::set-output name=unixtime::@$(date +%s)"' | |
- name: Build and run UI tests | |
run: xcodebuild clean test -scheme whatdid-ui-test -resultBundlePath ${{ runner.temp }}/test-results/bundle | |
- name: Gather logs | |
if: ${{ failure() }} | |
run: | | |
mkdir "${{ runner.temp }}/export" | |
mv "$(readlink ${{ runner.temp }}/test-results/bundle)" "${{ runner.temp }}/export/whatdid-uitest-failures-${{ github.run_number }}.xcresult" | |
- name: Upload test artifacts | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v2 | |
with: | |
name: whatdid-ui-tests-${{ github.run_number }} | |
path: ${{ runner.temp }}/export | |
unit-tests: | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Build and run unit tests | |
run: xcodebuild clean test -scheme whatdid-debug | tee build.stdout | |
- name: Report warnings and errors | |
run: | | |
# Check for errors, warnings, and TODOs. | |
# | |
# Each line will be something like: | |
# /path/to/whatdid/whatdid/main/SomeFile.swift:1234:56: warning: todo hello | |
# | |
# The output format for GH actions is: | |
# ::error file={name},line={line},endLine={endLine},title={title}::{message} | |
set -euo pipefail | |
{ grep -i '^/.*: \(warning\|error\): ' build.stdout || true; } | sort -u > warnings.txt | |
exit_code=0 | |
while read -r line; do | |
IFS=: read filename fileline filecol severity message <<< "$line" | |
severity="$(echo "$severity" | sed 's/^ *//')" | |
message="$(echo "$message" | sed 's/^ *//')" | |
title="Compiler $severity" | |
if grep -qi '^todo ' <<< "$message" ; then | |
severity=error | |
title="TODO detected" | |
message="$(echo "$message" | sed 's/^todo //i')" | |
fi | |
printf '::%s file=%s,line=%s,col=%s,title=%s::%s\n' "$severity" "$filename" "$fileline" "$filecol" "$title" "$message" | |
if [[ "$severity" == error ]]; then | |
exit_code=1 | |
fi | |
done < warnings.txt | |
exit $exit_code | |