Skip to content

Commit

Permalink
workflow: separate build and test jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
mgermerie committed Aug 21, 2023
1 parent 9370312 commit c3bc003
Showing 1 changed file with 67 additions and 24 deletions.
91 changes: 67 additions & 24 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ on:

jobs:

# Build bundle, doc and run tests (unit, functional and coverage)
tests:
name: Build and test validation
# Build bundle, doc and check linter
build:
name: Build bundle, check Linter and generate documentation
runs-on: ubuntu-latest
steps:

Expand All @@ -24,9 +24,9 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'npm'

# Install packages
# TODO: add cache npm to speed up installing
- name: Install packages
run: npm ci

Expand All @@ -43,30 +43,14 @@ jobs:
if: ${{ success() }}
run: npm run build

# Run unit tests
- name: Unit tests
run: npm run test-with-coverage_lcov

# Run functional tests
# TODO: functional tests don't stop if one fails
- name: Functional tests
if: ${{ success() }}
run: npm run test-functional

# Code coverage
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

# Build documentation
- name: Build documentation
if: ${{ success() && github.ref == 'refs/heads/master' }}
run: npm run doc -- -d buildDocs

# Prepare archive for deploying
- name: Archive production artifacts
if: ${{ success() && github.ref == 'refs/heads/master' }}
if: ${{ success() }}
uses: actions/upload-artifact@v3
with:
name: dist-itowns
Expand All @@ -92,11 +76,70 @@ jobs:
accessToken: ${{ secrets.GITHUB_TOKEN }}


# Unit and coverage tests
unit-and-coverage-tests:
name: Unit and coverage tests
needs: build
runs-on: ubuntu-latest
steps:

# Use specific Node.js version
- uses: actions/checkout@v3
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'npm'

# Install packages
- name: Install packages
run: npm ci

- name: Run unit tests
run: npm run test-with-coverage_lcov

# Code coverage
- name: Coveralls
if: ${{ success() }}
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}


# Functional tests
functional-tests:
name: Functional tests
needs: build
runs-on: ubuntu-latest
steps:

# Use specific Node.js version
- uses: actions/checkout@v3
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'npm'

# Install packages
- name: Install packages
run: npm ci

# Download artifact from build
- name: Download itowns bundle
uses: actions/download-artifact@v3
with:
name: dist-itowns

- name: Run functional tests
run: npm run test-functional


# Publish NPM package
publish:
name: Publish NPM package
if: ${{ github.ref == 'refs/heads/master' }}
needs: [tests, check-commit-message]
needs: [unit-and-coverage-tests, functional-tests, check-commit-message]
runs-on: ubuntu-latest
steps:

Expand Down Expand Up @@ -147,7 +190,7 @@ jobs:
deploy:
name: Deploy to itowns.github.io
if: ${{ github.ref == 'refs/heads/master' }}
needs: [tests, check-commit-message]
needs: [unit-and-coverage-tests, functional-tests, check-commit-message]
runs-on: ubuntu-latest
steps:

Expand Down Expand Up @@ -208,7 +251,7 @@ jobs:
release:
name: Release GitHub
if: ${{ github.ref == 'refs/heads/master' && startsWith( github.event.head_commit.message, 'release v' ) }}
needs: [tests, check-commit-message]
needs: [unit-and-coverage-tests, functional-tests, check-commit-message]
runs-on: ubuntu-latest
steps:

Expand Down

0 comments on commit c3bc003

Please sign in to comment.