mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-11-06 00:12:05 +08:00
79 lines
3.1 KiB
YAML
79 lines
3.1 KiB
YAML
name: Client linting
|
|
on:
|
|
push:
|
|
paths:
|
|
- 'client/**'
|
|
- '.github/workflows/js_lint.yaml'
|
|
pull_request:
|
|
paths:
|
|
- 'client/**'
|
|
- '.github/workflows/js_lint.yaml'
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
jobs:
|
|
client-unit-test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
- name: Read Node.js version
|
|
id: node-version
|
|
run: echo "version=$(cat 'client/.node_version')" >> $GITHUB_OUTPUT
|
|
- name: Setup node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ steps.node-version.outputs.version }}
|
|
cache: 'yarn'
|
|
cache-dependency-path: 'client/yarn.lock'
|
|
- run: yarn install --frozen-lockfile
|
|
working-directory: client
|
|
- name: Run ESLint
|
|
run: yarn run eslint
|
|
working-directory: client
|
|
- name: Run prettier checks
|
|
run: yarn run format-check
|
|
working-directory: client
|
|
# Run vue-tsc, compare with base, only fail if errors increased.
|
|
- name: Run vue-tsc on PR
|
|
id: current
|
|
working-directory: client
|
|
run: |
|
|
# Run vue-tsc in a simulated TTY to capture the summary output.
|
|
script -q -c 'npx vue-tsc --noEmit' current.log
|
|
# Extract the error count from the summary line; default to 0 if not found.
|
|
CURRENT_ERRORS=$(grep -oE 'Found [0-9]+ errors' current.log | head -1 | grep -oE '[0-9]+' || echo 0)
|
|
echo "Current vue-tsc errors: $CURRENT_ERRORS"
|
|
echo "current_errors=$CURRENT_ERRORS" >> $GITHUB_OUTPUT
|
|
# Check out the target base branch into a separate directory called "base".
|
|
- name: Checkout target base branch
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.pull_request.base.ref }}
|
|
- run: yarn install --frozen-lockfile
|
|
working-directory: client
|
|
# Run vue-tsc on the base branch and capture its error count.
|
|
- name: Run vue-tsc on base branch
|
|
id: baseline
|
|
working-directory: client
|
|
run: |
|
|
# Run vue-tsc in a simulated TTY and save the output to baseline.log.
|
|
script -q -c 'npx vue-tsc --noEmit' baseline.log
|
|
# Extract the error count from the summary line; default to 0 if not found.
|
|
BASE_ERRORS=$(grep -oE 'Found [0-9]+ errors' baseline.log | head -1 | grep -oE '[0-9]+' || echo 0)
|
|
echo "Baseline vue-tsc errors: $BASE_ERRORS"
|
|
echo "baseline_errors=$BASE_ERRORS" >> $GITHUB_OUTPUT
|
|
# Compare the error counts between the PR branch and the base branch.
|
|
- name: Compare vue-tsc error counts
|
|
run: |
|
|
CURRENT=${{ steps.current.outputs.current_errors }}
|
|
BASE=${{ steps.baseline.outputs.baseline_errors }}
|
|
echo "Current errors: ${CURRENT}"
|
|
echo "Baseline errors: ${BASE}"
|
|
if [ "$CURRENT" -gt "$BASE" ]; then
|
|
echo "vue-tsc error count increased from ${BASE} to ${CURRENT}. Failing the build."
|
|
exit 1
|
|
else
|
|
echo "vue-tsc error count did not increase."
|
|
fi |