Skip to content

Commit

Permalink
Merge pull request #36 from coverallsapp/combined-pr-branch
Browse files Browse the repository at this point in the history
Combined dependencies PR
  • Loading branch information
nebolsin committed Jun 16, 2023
2 parents 22a7f7a + 76ed4df commit fd4bd28
Show file tree
Hide file tree
Showing 12 changed files with 2,669 additions and 1,461 deletions.
63 changes: 25 additions & 38 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,43 @@ version: 2.1

orbs:
coveralls: coveralls/coveralls@2.2.0
node: circleci/node@1.1.6
node: circleci/node@5.1.0

jobs:
build-1:
executor:
name: node/default

executor: node/default
steps:
- checkout

- node/with-cache:
steps:
- run: npm install
- run: make test-coverage-1

- coveralls/upload:
parallel: true
flag_name: Test 1
verbose: true
- checkout
- node/install-packages
- run: npm test -- test/run1.js
- coveralls/upload:
parallel: true
flag_name: Test 1
verbose: true

build-2:
executor:
name: node/default

executor: node/default
steps:
- checkout

- node/with-cache:
steps:
- run: npm install
- run: make test-coverage-2

- coveralls/upload:
parallel: true
flag_name: Test 2
verbose: true
- checkout
- node/install-packages
- run: npm test -- test/run2.js
- coveralls/upload:
parallel: true
flag_name: Test 2
verbose: true

done:
executor:
name: node/default
executor: node/default

steps:
- coveralls/upload:
parallel_finished: true
carryforward: "Test 1,Test 2"
- coveralls/upload:
parallel_finished: true
carryforward: "Test 1,Test 2"

workflows:
test_parallel_then_upload:
jobs:
- build-1
- build-2
- done:
requires: [build-1, build-2]
- build-1
- build-2
- done:
requires: [ build-1, build-2 ]
38 changes: 38 additions & 0 deletions .github/workflows/coveralls-standalone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Standalone Coveralls Report

on: [ pull_request ]

# In this workflow we will:
# - wait for all sibling workflows to finish
# - download artifacts with coverage reports from `coveralls` workflow
# - send acquired artifacts to Coveralls as single report
jobs:
report:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Wait on tests (PR)
uses: lewagon/wait-on-check-action@v1.3.1
with:
# NOTE: The ref value should be different when triggered by pull_request event.
# See: https://github.com/lewagon/wait-on-check-action/issues/25.
ref: ${{ github.event.pull_request.head.sha }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10 # seconds
running-workflow-name: report # the name of this job
allowed-conclusions: success,skipped,cancelled,failure

- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{secrets.GITHUB_TOKEN}}
pr: ${{github.event.pull_request.number}}
workflow: coveralls.yml
workflow_conclusion: success

- uses: coverallsapp/github-action@v2
with:
format: lcov
debug: true
62 changes: 29 additions & 33 deletions .github/workflows/coveralls.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
name: Coveralls report
on:
push:
pull_request:
name: Test all platforms

on: [ push, pull_request ]

jobs:
report:
runs-on: ubuntu-latest
steps:
# NOTE: The ref value should be different when triggered by pull_request event.
# See: https://github.com/lewagon/wait-on-check-action/issues/25.
- name: Wait on tests (PR)
uses: lewagon/wait-on-check-action@v1.3.1
if: github.event_name == 'pull_request'
with:
ref: ${{ github.event.pull_request.head.sha }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10 # seconds
running-workflow-name: report # the name of this job
allowed-conclusions: success,skipped,cancelled,failure
test-linux:
uses: ./.github/workflows/test.yml
secrets:
token: ${{ secrets.COVERALLS_REPO_TOKEN }}

- name: Wait on tests (push)
if: github.event_name != 'pull_request'
uses: lewagon/wait-on-check-action@v1.3.1
with:
ref: ${{ github.sha }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10 # seconds
running-workflow-name: report # this job name
allowed-conclusions: success,skipped,cancelled,failure
test-macos:
uses: ./.github/workflows/test.yml
with:
os: macos
secrets:
token: ${{ secrets.COVERALLS_REPO_TOKEN }}

- uses: coverallsapp/github-action@v2
env:
COVERALLS_SERVICE_NUMBER: ${{ github.sha }}
with:
carryforward: "linux-1,linux-2,macos-2,macos-2,windows-1,windows-1"
parallel-finished: true
test-windows:
uses: ./.github/workflows/test.yml
with:
os: windows
secrets:
token: ${{ secrets.COVERALLS_REPO_TOKEN }}

coveralls:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [test-linux, test-macos, test-windows]
steps:
- uses: coverallsapp/github-action@v2
with:
carryforward: "linux-1,linux-2,macos-2,macos-2,windows-1,windows-1"
parallel-finished: true
30 changes: 0 additions & 30 deletions .github/workflows/linux.yml

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/macos.yml

This file was deleted.

64 changes: 64 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Reusable test workflow
run-name: Run tests on ${{ inputs.os }}

on:
workflow_call:
inputs:
build_id:
type: string
default: ${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}
description: |
Build identifier for the current run. This is sent as `service_number` to Coveralls.
os:
type: string
default: ubuntu
description: |
The type of machine to run the job on. Can be one of 'ubuntu' (default), 'macos', or 'windows'.
upload_coverage:
type: boolean
default: true
description: |
Whether to upload the coverage data to Coveralls.
store_coverage:
type: boolean
default: true
description: |
Whether to store the coverage data as an artifact.
secrets:
token:
required: true

env:
COVERALLS_SERVICE_NUMBER: ${{ inputs.build_id }}
COVERALLS_REPO_TOKEN: ${{ secrets.token }}

jobs:
test:
runs-on: ${{ inputs.os }}-latest
strategy:
matrix:
test_number: [ 1, 2 ]
outputs:
build_id: ${{ inputs.build_id }}
result: ${{ steps.coveralls.outputs.coveralls-api-result}}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
cache: npm
- run: npm ci
- run: npm test -- test/run${{ matrix.test_number }}.js
- name: Coveralls
id: coveralls
if: ${{ inputs.upload_coverage }}
uses: coverallsapp/github-action@v2
with:
parallel: true
flag-name: ${{ inputs.os }}-${{ matrix.test_number }}
debug: true
- uses: actions/upload-artifact@v3
if: ${{ inputs.store_coverage }}
with:
name: coverage-data-${{ inputs.os }}-${{ matrix.test_number }}
path: coverage/
29 changes: 0 additions & 29 deletions .github/workflows/windows.yml

This file was deleted.

23 changes: 17 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
sudo: false
---
os: linux
dist: jammy

language: node_js
node_js:
- "node"
node_js: lts/*
cache:
directories: ~/.npm

before_script: npm install -g npm@latest

env:
global:
- COVERALLS_PARALLEL=true
- COVERALLS_PARALLEL=true

install: npm ci

jobs:
include:
- script: COVERALLS_FLAG_NAME=test-1 make test-coveralls-1
- script: COVERALLS_FLAG_NAME=test-2 make test-coveralls-2
- script: npm test -- test/run1.js && COVERALLS_FLAG_NAME=test-1 npm run upload-coverage
- script: npm test -- test/run2.js && COVERALLS_FLAG_NAME=test-2 npm run upload-coverage

notifications:
webhooks: https://coveralls.io/webhook
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ pipeline {
stages {
stage('Setup') {
steps {
sh 'npm install'
sh 'npm ci'
}
}
stage('Build') {
steps {
sh 'make test-coveralls'
sh 'npm test && npm run upload-coverage'
}
}
}
Expand Down

0 comments on commit fd4bd28

Please sign in to comment.