fix: detect changed files if they r surrounded by quotes in diff #74
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: 'π PR' | |
on: | |
pull_request: | |
branches: | |
- '*' | |
concurrency: | |
group: ${{ github.head_ref }} | |
cancel-in-progress: true | |
env: | |
GITHUB_NPM_TOKEN: ${{ secrets.LMND_GITHUB_TOKEN }} | |
NODE_AUTH_TOKEN: ${{ secrets.LMND_GITHUB_TOKEN }} | |
jobs: | |
setup: | |
name: 'π¨ Setup' | |
runs-on: ubuntu-latest | |
outputs: | |
projects: ${{ steps.affectedProjects.outputs.affectedProjects }} | |
numOfAffected: ${{ steps.numOfAffected.outputs.numOfAffected }} | |
commitHash: ${{ steps.commitHash.outputs.commitHash }} | |
steps: | |
- name: 'π¨ Init node' | |
uses: actions/setup-node@v3 | |
with: | |
registry-url: https://registry.npmjs.org/ | |
scope: '@traf' | |
node-version: 18 | |
- name: 'π¨ Checkout code' | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
fetch-depth: 0 | |
token: ${{ env.GITHUB_FORCE_PUSH_TOKEN || github.token }} | |
- name: 'π¨ Cache node modules' | |
id: cache-nodemodules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: 'π¨ Install dependencies' | |
shell: bash | |
if: steps.cache-nodemodules.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: 'π Get Affected Projects' | |
id: affectedProjects | |
run: | | |
affectedProjects=$(npx nx run nx:print-affected --base=origin/main --json=true | sed -n -e '/^\[/p') | |
echo $affectedProjects | |
echo "affectedProjects=$affectedProjects" >> $GITHUB_OUTPUT | |
- name: 'π’ Get Number of Affected Projects' | |
id: numOfAffected | |
run: | | |
numOfAffected="$(echo '${{ steps.affectedProjects.outputs.affectedProjects }}' | jq length)" | |
echo $numOfAffected | |
echo "numOfAffected=$numOfAffected" >> $GITHUB_OUTPUT | |
- name: '#οΈβ£ Get commit hash' | |
id: commitHash | |
run: | | |
commitHash=$(git rev-parse --short HEAD) | |
echo $commitHash | |
echo "commitHash=$commitHash" >> $GITHUB_OUTPUT | |
verify: | |
name: 'π Verify static ${{ matrix.project }}' | |
if: | | |
needs.setup.outputs.numOfAffected != 0 && | |
(!contains(github.event.head_commit.message, 'skip ci') || github.event.pull_request.merged == 'true') | |
runs-on: ubuntu-latest | |
needs: | |
- setup | |
strategy: | |
fail-fast: false | |
matrix: | |
project: ${{ fromJson(needs.setup.outputs.projects) }} | |
steps: | |
- name: 'π¨ Init node' | |
uses: actions/setup-node@v3 | |
with: | |
registry-url: https://registry.npmjs.org/ | |
scope: '@traf' | |
node-version: 18 | |
- name: 'π¨ Checkout code' | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
fetch-depth: 0 | |
token: ${{ env.GITHUB_FORCE_PUSH_TOKEN || github.token }} | |
- name: 'π¨ Cache node modules' | |
id: cache-nodemodules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: 'π¨ Install dependencies' | |
shell: bash | |
if: steps.cache-nodemodules.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: 'π tsc ${{ matrix.project }}' | |
run: npx nx tsc ${{ matrix.project }} | |
- name: 'π lint ${{ matrix.project }}' | |
run: npx nx lint ${{ matrix.project }} | |
- name: 'π spell ${{ matrix.project }}' | |
run: npx nx spell ${{ matrix.project }} | |
verify-success: | |
name: 'Verify Success' | |
needs: | |
- setup | |
- verify | |
if: always() && needs.setup.result == 'success' | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'β Run if no affected packages' | |
if: needs.setup.outputs.numOfAffected == 0 | |
run: | | |
echo "β No projects to verify" | |
exit 0 | |
- name: 'β Run if affected packages' | |
if: needs.setup.outputs.numOfAffected != 0 | |
run: | | |
if [ "${{ needs.verify.result }}" != "success" ] | |
then | |
echo "β Look at the verify jobs and see which library failed" | |
exit 1 | |
else | |
echo "β All verify jobs passed" | |
exit 0 | |
fi | |
test: | |
name: 'π§ͺ Test ${{ matrix.project }}' | |
if: | | |
needs.setup.outputs.numOfAffected != 0 && | |
(!contains(github.event.head_commit.message, 'skip ci') || github.event.pull_request.merged == 'true') | |
runs-on: ubuntu-latest | |
needs: | |
- setup | |
strategy: | |
fail-fast: false | |
matrix: | |
project: ${{ fromJson(needs.setup.outputs.projects) }} | |
steps: | |
- name: 'π¨ Init node' | |
uses: actions/setup-node@v3 | |
with: | |
registry-url: https://registry.npmjs.org/ | |
scope: '@traf' | |
node-version: 18 | |
- name: 'π¨ Checkout code' | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
fetch-depth: 0 | |
token: ${{ env.GITHUB_FORCE_PUSH_TOKEN || github.token }} | |
- name: 'π¨ Cache node modules' | |
id: cache-nodemodules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: 'π¨ Install dependencies' | |
shell: bash | |
if: steps.cache-nodemodules.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: "π§ͺ Run ${{ matrix.project }}'s Tests" | |
run: npx nx test ${{ matrix.project }} --coverage --coverageReporters='lcov' | |
test-success: | |
name: 'Test Success' | |
needs: | |
- setup | |
- test | |
if: always() && needs.setup.result == 'success' | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'β Run if no affected packages' | |
if: needs.setup.outputs.numOfAffected == 0 | |
run: | | |
echo "β No projects to test" | |
exit 0 | |
- name: 'β Run if affected packages' | |
if: needs.setup.outputs.numOfAffected != 0 | |
run: | | |
if [ "${{ needs.test.result }}" != "success" ] | |
then | |
echo "β Look at the test jobs and see which library failed" | |
exit 1 | |
else | |
echo "β All test jobs passed" | |
exit 0 | |
fi | |
build: | |
name: 'π€ Build' | |
if: | | |
needs.setup.outputs.numOfAffected != 0 && | |
(!contains(github.event.head_commit.message, 'skip ci') || github.event.pull_request.merged == 'true') | |
needs: setup | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
project: ${{ fromJson(needs.setup.outputs.projects) }} | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
- name: 'π¨ Init node' | |
uses: actions/setup-node@v3 | |
with: | |
registry-url: https://registry.npmjs.org/ | |
scope: '@traf' | |
node-version: 18 | |
- name: 'π¨ Checkout code' | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
fetch-depth: 0 | |
token: ${{ env.GITHUB_FORCE_PUSH_TOKEN || github.token }} | |
- name: 'π¨ Cache node modules' | |
id: cache-nodemodules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: 'π¨ Install dependencies' | |
shell: bash | |
if: steps.cache-nodemodules.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: 'ποΈ Build ${{ matrix.project }}' | |
run: npx nx build ${{ matrix.project }} -- --optimization | |
env: | |
STAGE: 'staging' | |
build-success: | |
name: 'Build Success' | |
needs: | |
- setup | |
- build | |
if: always() && needs.setup.result == 'success' | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'β Run if no affected packages' | |
if: needs.setup.outputs.numOfAffected == 0 | |
run: | | |
echo "β No projects to verify" | |
exit 0 | |
- name: 'β Run if affected packages' | |
if: needs.setup.outputs.numOfAffected != 0 | |
run: | | |
if [ "${{ needs.build.result }}" != "success" ] | |
then | |
echo "β Look at the build jobs and see which library failed" | |
exit 1 | |
else | |
echo "β All build and publish jobs passed" | |
exit 0 | |
fi |