Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
ci: conditional execution of tests on file changes (#1448)
Browse files Browse the repository at this point in the history
  • Loading branch information
jthegedus authored Jan 25, 2023
1 parent f0fe961 commit b45f12c
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Docs
name: Documentation

on:
# trigger deployment on every push to main branch
# trigger deployment on push to master branch when changes to docs/**
push:
paths:
- "docs/**"
Expand All @@ -11,7 +11,7 @@ on:
workflow_dispatch:

jobs:
docs:
deploy:
runs-on: ubuntu-latest
defaults:
run:
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:

- name: Build VuePress site
run: npm run build

- name: Bundle CNAME with site dist
run: cp CNAME .vuepress/dist

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/semantic-pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint PR
name: Lint

on:
pull_request_target:
Expand Down
84 changes: 82 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tests
name: Test

on:
push:
Expand All @@ -11,7 +11,45 @@ env:
NUSHELL_VERSION: 0.73.0

jobs:
detect-changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
documentation: ${{ steps.filter.outputs.documentation }}
cli: ${{ steps.filter.outputs.cli }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
documentation:
- '.github/workflows/**'
- 'docs/**'
- '.tool-versions'
cli:
- '.github/workflows/**'
- 'bin/**'
- 'lib/**'
- 'scripts/**'
- 'test/**'
- '.tool-versions'
- 'asdf.elv'
- 'asdf.fish'
- 'asdf.nu'
- 'asdf.sh'
ubuntu:
needs: detect-changes
# only run if
# - changes to cli
if: ${{ needs.detect-changes.outputs.cli == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand Down Expand Up @@ -52,8 +90,12 @@ jobs:
run: bats test
env:
GITHUB_API_TOKEN: ${{ github.token }}

macos:
needs: detect-changes
# only run if
# - changes to cli
if: ${{ needs.detect-changes.outputs.cli == 'true' }}
runs-on: macos-latest
steps:
- name: Checkout code
Expand All @@ -73,3 +115,41 @@ jobs:
run: bats test
env:
GITHUB_API_TOKEN: ${{ github.token }}

documentation-site:
needs: detect-changes
# only run if
# - changes to documentation
# - pull_request (workflows/docs.yml deploys on main branch)
if: ${{ github.event_name == 'pull_request' && needs.detect-changes.outputs.documentation == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# fetch all commits to get git log info for Vuepress
fetch-depth: 0

# only run steps past here if changes to docs/** directory
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"

- name: Cache dependencies
uses: actions/cache@v3
id: npm-cache
with:
path: |
docs/node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('docs/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Install dependencies
if: steps.npm-cache.outputs.cache-hit != 'true'
working-directory: docs/
run: npm install

- name: Check errors by biulding Documentation site
working-directory: docs/
run: npm run build

0 comments on commit b45f12c

Please sign in to comment.