From 9a7aaa71cecde23f357267413a04093ec5a00d1d Mon Sep 17 00:00:00 2001 From: Paul Robert Lloyd Date: Thu, 21 Nov 2024 17:50:26 +0000 Subject: [PATCH] Scope pull-request workflows to paths --- .github/workflows/analyse.yml | 24 +++++++++++ .github/workflows/lint.yml | 18 ++++++++ .github/workflows/pull-request.yml | 68 ------------------------------ .github/workflows/test.yml | 52 +++++++++++++++++++++++ 4 files changed, 94 insertions(+), 68 deletions(-) create mode 100644 .github/workflows/analyse.yml create mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/pull-request.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/analyse.yml b/.github/workflows/analyse.yml new file mode 100644 index 000000000..aad7706f4 --- /dev/null +++ b/.github/workflows/analyse.yml @@ -0,0 +1,24 @@ +name: Pull request + +on: pull_request + +jobs: + analyse: + name: Sonar analysis + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + - name: Install dependencies + run: npm ci + - name: Sonar analysis + uses: sonarsource/sonarcloud-github-action@master + with: + projectBaseDir: . + env: + GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..585d9c04d --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,18 @@ +name: Pull request + +on: pull_request + +jobs: + lint: + name: Code style checks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + - name: Install dependencies + run: npm ci + - name: Run linter + run: npm run lint diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml deleted file mode 100644 index 7b1392220..000000000 --- a/.github/workflows/pull-request.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: Pull request - -on: pull_request - -jobs: - sonar_analysis: - name: Sonar analysis - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'npm' - - name: Install dependencies - run: npm ci - - name: Sonar analysis - uses: sonarsource/sonarcloud-github-action@master - with: - projectBaseDir: . - env: - GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - - linting: - name: Code style checks - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'npm' - - name: Install dependencies - run: npm ci - - name: Run linting - run: npm run lint - - tests: - name: Javascript unit tests - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'npm' - - name: Install dependencies - run: npm ci - - name: Run tests - run: npm test - - ui_tests: - name: Visual regression tests - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'npm' - - name: Install dependencies - run: npm ci - - name: Run tests - run: npm test - - name: Run backstop - run: npm run backstop:ci diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..57a78f5b3 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,52 @@ +name: Pull request + +on: pull_request + +jobs: + tests: + name: Javascript unit tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + - name: Get changed files + id: changed-tests + uses: tj-actions/changed-files@v45 + with: + files: | + packages/**/*.js + packages/**/*.scss + dist/app/components/**/*.html + - name: Install dependencies + if: steps.changed-tests.outputs.any_changed == 'true' + run: npm ci + - name: Run tests + if: steps.changed-tests.outputs.any_changed == 'true' + run: npm test + + ui_tests: + name: Visual regression tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + - name: Get changed files + id: changed-ui_tests + uses: tj-actions/changed-files@v45 + with: + files: | + packages/** + tests/** + app/** + - name: Install dependencies + if: steps.changed-ui_tests.outputs.any_changed == 'true' + run: npm ci + - name: Run backstop + if: steps.changed-ui_tests.outputs.any_changed == 'true' + run: npm run backstop:ci