Skip to content
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
40 changes: 30 additions & 10 deletions .github/workflows/build-status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
branches:
- master

permissions:
contents: read

jobs:
build-and-test:
name: Build And Test ${{matrix.os}}
Expand Down Expand Up @@ -81,21 +84,37 @@ jobs:
uses: actions/download-artifact@v8
with:
name: coverage-reports
path: ${{ runner.temp }}/artifacts

- name: Set Coverage Report Paths
id: coverage-paths
- name: Download Codacy Coverage Reporter
env:
CODACY_REPORTER_VERSION: 14.1.3
CODACY_REPORTER_SHA256: 15c5f052207d27b8501ab5d5910c68c206ea70b0157ee1725132780530580875
run: |
readarray -d '' coveragePathArray < <(find . -name "coverage.cobertura.xml" -print0)
coveragePaths=$(printf -- "-r %s " "${coveragePathArray[@]}")
echo "COVERAGE_REPORT_PATHS=$coveragePaths" >> $GITHUB_OUTPUT
reporter="$RUNNER_TEMP/codacy/codacy-coverage-reporter"
mkdir -p "$(dirname "$reporter")"
curl --proto "=https" --proto-redir "=https" --tlsv1.2 -fsSL --retry 3 -o "$reporter" \
"https://github.com/codacy/codacy-coverage-reporter/releases/download/${CODACY_REPORTER_VERSION}/codacy-coverage-reporter-linux"
echo "${CODACY_REPORTER_SHA256} ${reporter}" | sha256sum --check --strict
chmod +x "$reporter"

- name: Publish Code Coverage Results
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
run: |
auth="--project-token ${{ secrets.CODACY_PROJECT_TOKEN }}"
reports=()
while IFS= read -r -d '' file; do
reports+=(-r "$file")
done < <(find "$RUNNER_TEMP/artifacts" -type f -name "coverage.cobertura.xml" -print0)

if [ ${#reports[@]} -eq 0 ]; then
echo "::error::No coverage reports found in artifact"
exit 1
fi

bash <(curl -Ls https://coverage.codacy.com/get.sh) report $auth \
${{ steps.coverage-paths.outputs.COVERAGE_REPORT_PATHS }} --partial &&\
bash <(curl -Ls https://coverage.codacy.com/get.sh) final $auth
reporter="$RUNNER_TEMP/codacy/codacy-coverage-reporter"
"$reporter" report "${reports[@]}" --partial &&\
"$reporter" final

report-benchmark-results:
needs: build-and-test
Expand All @@ -108,6 +127,7 @@ jobs:
uses: actions/download-artifact@v8
with:
name: benchmark-results
path: ${{ runner.temp }}/artifacts

- name: 'Report benchmark result'
run: cat ./NHapi.Benchmarks.LargeEmbeddedFileTest-report-github.md >> $GITHUB_STEP_SUMMARY
run: cat "$RUNNER_TEMP/artifacts/NHapi.Benchmarks.LargeEmbeddedFileTest-report-github.md" >> "$GITHUB_STEP_SUMMARY"
51 changes: 40 additions & 11 deletions .github/workflows/publish-pr-coverage-results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,65 @@ on:
types:
- completed

permissions:
contents: read

jobs:
publish-test-results:
name: Publish Code Coverage Results
runs-on: ubuntu-latest
permissions:
actions: read
# the build-and-test job might be skipped, we don't need to run this job then
if: >
if: >-
${{ github.event.workflow_run.event == 'pull_request' &&
( github.event.workflow_run.conclusion == 'success' ||
github.event.workflow_run.conclusion == 'failure' ) }}
steps:

# The artifact comes from an untrusted pull request build. It is downloaded
# outside the workspace, nothing in it is ever executed, and only regular
# coverage.cobertura.xml files are read from it as data.
- name: 'Download artifact'
uses: actions/download-artifact@v8
with:
name: coverage-reports
path: ${{ runner.temp }}/artifacts
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}

- name: Set Coverage Report Paths
id: coverage-paths
- name: Download Codacy Coverage Reporter
env:
CODACY_REPORTER_VERSION: 14.1.3
CODACY_REPORTER_SHA256: 15c5f052207d27b8501ab5d5910c68c206ea70b0157ee1725132780530580875
run: |
readarray -d '' coveragePathArray < <(find . -name "coverage.cobertura.xml" -print0)
coveragePaths=$(printf -- "-r %s " "${coveragePathArray[@]}")
echo "COVERAGE_REPORT_PATHS=$coveragePaths" >> $GITHUB_OUTPUT
reporter="$RUNNER_TEMP/codacy/codacy-coverage-reporter"
mkdir -p "$(dirname "$reporter")"
curl --proto "=https" --proto-redir "=https" --tlsv1.2 -fsSL --retry 3 -o "$reporter" \
"https://github.com/codacy/codacy-coverage-reporter/releases/download/${CODACY_REPORTER_VERSION}/codacy-coverage-reporter-linux"
echo "${CODACY_REPORTER_SHA256} ${reporter}" | sha256sum --check --strict
chmod +x "$reporter"

- name: Publish Code Coverage Results
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
run: |
auth="--project-token ${{ secrets.CODACY_PROJECT_TOKEN }}"
if [[ ! "$HEAD_SHA" =~ ^[0-9a-f]{40}$ ]]; then
echo "::error::Unexpected head SHA format"
exit 1
fi

reports=()
while IFS= read -r -d '' file; do
reports+=(-r "$file")
done < <(find "$RUNNER_TEMP/artifacts" -type f -name "coverage.cobertura.xml" -print0)

if [ ${#reports[@]} -eq 0 ]; then
echo "::error::No coverage reports found in artifact"
exit 1
fi

bash <(curl -Ls https://coverage.codacy.com/get.sh) report $auth \
--commit-uuid ${{ github.event.workflow_run.head_sha }} \
${{ steps.coverage-paths.outputs.COVERAGE_REPORT_PATHS }} --partial &&\
bash <(curl -Ls https://coverage.codacy.com/get.sh) final $auth
reporter="$RUNNER_TEMP/codacy/codacy-coverage-reporter"
"$reporter" report --commit-uuid "$HEAD_SHA" "${reports[@]}" --partial &&\
"$reporter" final
12 changes: 10 additions & 2 deletions .github/workflows/publish-pr-test-results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ on:
types:
- completed

permissions:
contents: read

jobs:
publish-test-results:
name: Publish Test Results
runs-on: ubuntu-latest
permissions:
actions: read
checks: write
pull-requests: write
# the build-and-test job might be skipped, we don't need to run this job then
if: >
if: >-
${{ github.event.workflow_run.event == 'pull_request' &&
( github.event.workflow_run.conclusion == 'success' ||
github.event.workflow_run.conclusion == 'failure' ) }}
Expand All @@ -21,6 +28,7 @@ jobs:
uses: actions/download-artifact@v8
with:
name: unit-test-results
path: artifacts/unit-test-results
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}

Expand All @@ -30,6 +38,6 @@ jobs:
check_name: Unit Test Results
github_token: ${{ secrets.GITHUB_TOKEN }}
commit: ${{ github.event.workflow_run.head_sha }}
trx_files: "**/*.trx"
trx_files: "artifacts/unit-test-results/**/*.trx"
report_individual_runs: true
check_run_annotations: all tests, skipped tests
3 changes: 3 additions & 0 deletions .github/workflows/receive-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Receive Pull Request

on: [pull_request]

permissions:
contents: read

jobs:
build-and-test:
name: Build And Test ${{matrix.os}}
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/report-benchmark-results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ on:
types:
- completed

permissions:
contents: read

jobs:
publish-test-results:
name: Report Benchmark Results
runs-on: ubuntu-latest
permissions:
actions: read
# the build-and-test job might be skipped, we don't need to run this job then
if: >
if: >-
${{ github.event.workflow_run.event == 'pull_request' &&
( github.event.workflow_run.conclusion == 'success' ||
github.event.workflow_run.conclusion == 'failure' ) }}
Expand All @@ -20,8 +25,9 @@ jobs:
uses: actions/download-artifact@v8
with:
name: benchmark-results
path: ${{ runner.temp }}/artifacts
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}

- name: 'Report benchmark result'
run: cat ./NHapi.Benchmarks.LargeEmbeddedFileTest-report-github.md >> $GITHUB_STEP_SUMMARY
run: cat "$RUNNER_TEMP/artifacts/NHapi.Benchmarks.LargeEmbeddedFileTest-report-github.md" >> "$GITHUB_STEP_SUMMARY"
Loading