Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate coverage collection #200

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 27 additions & 17 deletions .github/workflows/main-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,24 @@ on:
- "docs/"
- "**.md"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: Coverage - Calculation
runs-on: ubuntu-latest
outputs:
workspaces: ${{ steps.workspaces.outputs.directories }}
steps:
# Cloning
- uses: actions/checkout@v3

# Collection
- name: Collect NPM workspaces
id: workspaces
uses: secondtruth/[email protected]
with:
files-glob: "*/*/package.json"
unique: true

# Setup and Caching
- name: Use latest Node.js LTS version
uses: actions/setup-node@v3
Expand Down Expand Up @@ -48,7 +54,7 @@ jobs:

# Send coverage information to Coveralls
coverage:
name: Coverage(${{ matrix.package }}) - Collection
name: Coverage(${{ matrix.workspace }}) - Collection
needs: test
runs-on: ubuntu-latest
defaults:
Expand All @@ -59,14 +65,7 @@ jobs:
fail-fast: false

matrix:
# Collect coverage for all packages and plugins
package:
- libraries/analysis-javascript
- libraries/ast-visitor-javascript
- libraries/instrumentation-javascript
- libraries/search-javascript
- plugins/plugin-javascript-event-listener-state-storage
- tools/javascript
workspace: ${{ fromJson(needs.test.outputs.workspaces) }}

steps:
# Cloning
Expand All @@ -77,17 +76,28 @@ jobs:
with:
name: coverage-results

# Check if the coverage file exists
- name: Check for coverage files
id: check_files
uses: andstor/file-existence-action@v2
with:
files: ${{ matrix.workspace }}/coverage/lcov.info

# Run the Coveralls action which uploads the lcov.info file
- name: Coveralls(${{ matrix.package }})
- name: Coveralls(${{ matrix.workspace }})
uses: coverallsapp/github-action@master
if: steps.check_files.outputs.files_exists == 'true'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

# We collect all coverages in parallel
parallel: true
flag-name: ${{ matrix.package }}
base-path: ${{ matrix.package }}/
path-to-lcov: ${{ github.workspace }}/${{ matrix.package }}/coverage/lcov.info
flag-name: ${{ matrix.workspace }}
base-path: ${{ matrix.workspace }}/
path-to-lcov: ${{ matrix.workspace }}/coverage/lcov.info

- if: steps.check_files.outputs.files_exists == 'false'
run: echo "::warning file=${{ matrix.workspace }}/coverage/lcov.info::Coverage file missing"

# Indicate sending coverage to Coveralls is finished
coverage-finished:
Expand Down
46 changes: 29 additions & 17 deletions .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,21 @@ jobs:
architecture: x64
report_coverage: true

outputs:
workspaces: ${{ steps.workspaces.outputs.directories }}

steps:
# Cloning
- uses: actions/checkout@v3

# Collection
- name: Collect NPM workspaces
id: workspaces
uses: secondtruth/[email protected]
with:
files-glob: "*/*/package.json"
unique: true

# Setup and Caching
- name: Use Node.js ${{ matrix.node-version }} (${{ matrix.architecture }})
uses: actions/setup-node@v3
Expand Down Expand Up @@ -77,13 +88,9 @@ jobs:
path: ${{ github.workspace }}/**/test-results.json
reporter: mocha-json

# Mark job as successful even if the artifact or test report fails
- run: exit 0
if: ${{ steps.test.outcome == 'success' }}

# Send coverage information to Coveralls
coverage:
name: Coverage(${{ matrix.package }}) - Collection
name: Coverage(${{ matrix.workspace }}) - Collection
needs: test
runs-on: ubuntu-latest
defaults:
Expand All @@ -94,35 +101,40 @@ jobs:
fail-fast: false

matrix:
# Collect coverage for all packages and plugins
package:
- libraries/analysis-javascript
- libraries/ast-visitor-javascript
- libraries/instrumentation-javascript
- libraries/search-javascript
- plugins/plugin-javascript-event-listener-state-storage
- tools/javascript
workspace: ${{ fromJson(needs.test.outputs.workspaces) }}

steps:
# Cloning
- uses: actions/checkout@v3

# Download test results
- uses: actions/download-artifact@v3
id: artifact
with:
name: coverage-results

# Check if the coverage file exists
- name: Check for coverage files
id: check_files
uses: andstor/file-existence-action@v2
with:
files: ${{ matrix.workspace }}/coverage/lcov.info

# Run the Coveralls action which uploads the lcov.info file
- name: Coveralls(${{ matrix.package }})
- name: Coveralls(${{ matrix.workspace }})
uses: coverallsapp/github-action@master
if: steps.check_files.outputs.files_exists == 'true'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

# We collect all coverages in parallel
parallel: true
flag-name: ${{ matrix.package }}
base-path: ${{ matrix.package }}/
path-to-lcov: ${{ github.workspace }}/${{ matrix.package }}/coverage/lcov.info
flag-name: ${{ matrix.workspace }}
base-path: ${{ matrix.workspace }}/
path-to-lcov: ${{ matrix.workspace }}/coverage/lcov.info

- if: steps.check_files.outputs.files_exists == 'false'
run: echo "::warning file=${{ matrix.workspace }}/coverage/lcov.info::Coverage file missing"

# Indicate sending coverage to Coveralls is finished
coverage-finished:
Expand Down