Skip to content

feat(core): find references for files not in project #44

feat(core): find references for files not in project

feat(core): find references for files not in project #44

Workflow file for this run

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