Skip to content

Test action

Test action #5

Workflow file for this run

name: Check for New TypeScript Errors
on:
workflow_dispatch:
pull_request:
branches:
- main
- test-action
jobs:
check-tsc-errors:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Fetch target and PR branches
run: git fetch origin ${{ github.base_ref }}:${{ github.base_ref }} ${{ github.head_ref }}:${{ github.head_ref }}
- name: Download artifact from target branch
id: download-artifact
uses: actions/download-artifact@v2
with:
name: ${{ github.base_ref_slug }}-tsc-output
path: base-tsc-output
continue-on-error: true
- name: Check if artifact exists
id: check-artifact
run: |
if [ -f base-tsc-output/tsc_output.txt ]; then
echo "Artifact found."
echo "artifact-found=true" >> $GITHUB_ENV
else
echo "Artifact not found."
echo "artifact-found=false" >> $GITHUB_ENV
fi
- name: Generate base errors if artifact not found
if: env.artifact-found == 'false'
run: |
set -e
echo "Checking out base branch"
git checkout ${{ github.base_ref }}
echo "Creating output directory"
mkdir -p base-tsc-output
echo "Running tsc"
npx tsc --noEmit --pretty false 2> base-tsc-output/tsc_errors.txt || { echo 'tsc command failed'; cat base-tsc-output/tsc_errors.txt; exit 1; }
echo "Extracting errors"
grep -oE '^[^ ]+.ts:[0-9]+:[0-9]+' base-tsc-output/tsc_errors.txt | sort -u > base-tsc-errors.txt || { echo 'grep command failed'; exit 1; }
- name: Extract errors from artifact if found
if: env.artifact-found == 'true'
run: |
grep -oE '^[^ ]+.ts:[0-9]+:[0-9]+' base-tsc-output/tsc_output.txt | sort -u > base-tsc-errors.txt || { echo 'grep command failed'; exit 1; }
- name: Checkout PR branch
run: git checkout ${{ github.head_ref }}
- name: Install dependencies for PR branch
uses: ./.github/actions/setup
- name: Run tsc on PR branch
run: |
npx tsc --noEmit --pretty false 2> head-tsc-output.txt || { echo 'tsc c