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

CI: Push coverage into GH artifacts #266

Merged
merged 4 commits into from
Jul 20, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/container-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
Expand Down
81 changes: 81 additions & 0 deletions .github/workflows/coverage-upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Coverage Upload

on:
workflow_run:
workflows: [Tests]
types:
- completed

jobs:
run_tests:
runs-on: ubuntu-latest
steps:
# https://github.com/actions/github-script
# Based on: https://github.com/orgs/community/discussions/34652
- name: 'Download artifact'
uses: actions/github-script@v7
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifactXmlRpc = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "coverage-report-typescript-xmlrpc"
})[0];
let matchArtifactApi = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "coverage-report-cobbler-api"
})[0];
let matchArtifactFrontend = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "coverage-report-cobbler-frontend"
})[0];
let downloadXmlRpc = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifactXmlRpc.id,
archive_format: 'zip',
});
let downloadApi = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifactApi.id,
archive_format: 'zip',
});
let downloadFrontend = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifactFrontend.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/coverage-report-xmlrpc.zip`, Buffer.from(downloadXmlRpc.data));
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/coverage-report-api.zip`, Buffer.from(downloadApi.data));
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/coverage-report-frontend.zip`, Buffer.from(downloadFrontend.data));
- name: 'Unzip typescript-xmlrpc artifact'
run: unzip coverage-report-xmlrpc.zip
- name: 'Unzip cobbler-api artifact'
run: unzip coverage-report-api.zip
- name: 'Unzip cobbler-frontend artifact'
run: unzip coverage-report-frontend.zip
# https://github.com/actions/download-artifact
# - name: Download artifact
# id: download-artifact
# uses: actions/download-artifact@v4
# with:
# run-id: ${{ github.event.workflow_run.id }}
# https://github.com/codacy/codacy-coverage-reporter-action
# - name: Run codacy-coverage-reporter
# uses: codacy/codacy-coverage-reporter-action@v1
# with:
# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
# coverage-reports: coverage.xml
- name: Publish Code Coverage Results
run: |
auth="--project-token ${{ secrets.CODACY_PROJECT_TOKEN }}"
commit_uuid="--commit-uuid ${{ github.event.workflow_run.head_sha }}"

bash <(curl -Ls https://coverage.codacy.com/get.sh) report $auth $commit_uuid -r coverage/typescript-xmlrpc/lcov.info --partial &&\
bash <(curl -Ls https://coverage.codacy.com/get.sh) report $auth $commit_uuid -r coverage/cobbler-api/lcov.info --partial &&\
bash <(curl -Ls https://coverage.codacy.com/get.sh) report $auth $commit_uuid -r coverage/cobbler-frontend/lcov.info --partial &&\
bash <(curl -Ls https://coverage.codacy.com/get.sh) final $auth $commit_uuid
6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Cache node modules
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
Expand All @@ -36,7 +36,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
uses: actions/checkout@4
- name: Download Artifact
uses: actions/download-artifact@master
with:
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ jobs:
matrix:
node-version: [ 18.x ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Node ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v2
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand All @@ -36,9 +36,9 @@ jobs:
matrix:
node-version: [ 18.x ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Node ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v2
Expand All @@ -57,12 +57,12 @@ jobs:
matrix:
node-version: [ 18.x ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Node ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v2
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand Down
49 changes: 29 additions & 20 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
env:
CHROME_BIN: /usr/bin/google-chrome
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand All @@ -28,19 +28,23 @@ jobs:
- name: Build project typescript-xmlrpc
run: npm run build typescript-xmlrpc
- name: Test Project
run: npm run test:ci typescript-xmlrpc
- uses: codecov/codecov-action@v2
run: npm run test:ci typescript-xmlrpc --code-coverage
# https://github.com/actions/upload-artifact
- name: Upload coverage report to GH artifacts
uses: actions/upload-artifact@v4
with:
flags: unit-typescript-xmlrpc
name: coverage-report-typescript-xmlrpc
path: coverage/typescript-xmlrpc/lcov.info
if-no-files-found: error
unit-cobbler-api:
runs-on: ubuntu-latest
container:
image: timbru31/node-chrome
env:
CHROME_BIN: /usr/bin/google-chrome
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand All @@ -53,19 +57,23 @@ jobs:
- name: Build project cobbler-api
run: npm run build cobbler-api
- name: Test Project
run: npm run test:ci cobbler-api
- uses: codecov/codecov-action@v2
run: npm run test:ci cobbler-api --code-coverage
# https://github.com/actions/upload-artifact
- name: Upload coverage report to GH artifacts
uses: actions/upload-artifact@v4
with:
flags: unit-cobbler-api
name: coverage-report-cobbler-api
path: coverage/cobbler-api/lcov.info
if-no-files-found: error
unit-cobbler-frontend:
runs-on: ubuntu-latest
container:
image: timbru31/node-chrome
env:
CHROME_BIN: /usr/bin/google-chrome
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand All @@ -80,10 +88,14 @@ jobs:
- name: Build project
run: npm run build cobbler-frontend
- name: Test Project
run: npm run test:ci cobbler-frontend
- uses: codecov/codecov-action@v2
run: npm run test:ci cobbler-frontend --code-coverage
# https://github.com/actions/upload-artifact
- name: Upload coverage report to GH artifacts
uses: actions/upload-artifact@v4
with:
flags: unit-cobbler-frontend
name: coverage-report-cobbler-frontend
path: coverage/cobbler-frontend/lcov.info
if-no-files-found: error
e2e-cobbler-frontend:
if: ${{ false }} # disable for now; we don't have e2e tests currently
runs-on: ubuntu-latest
Expand All @@ -92,8 +104,8 @@ jobs:
env:
CHROME_BIN: /usr/bin/google-chrome
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand All @@ -109,6 +121,3 @@ jobs:
run: npm run build cobbler-frontend
- name: E2E Tests
run: npm run e2e -- --configuration=ci
- uses: codecov/codecov-action@v2
with:
flags: e2e-cobbler-frontend
Loading