Skip to content

Commit

Permalink
Get actions running
Browse files Browse the repository at this point in the history
  • Loading branch information
reubeno committed May 11, 2024
1 parent ba93393 commit 308b9df
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 24 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/ci-reports.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: "PR Reports"
on:
workflow_run:
workflows: ["CI"]
types:
- completed

permissions:
actions: read
pull-requests: write

jobs:
report:
name: "Report"
runs-on: ubuntu-latest
steps:
- name: Find workflow run
id: find-run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: octokit/[email protected]
with:
route: GET /repos/${{ github.event.workflow_run.repository.full_name }}/actions/runs/${{ github.event.workflow_run.id }}

- name: Extract PR number
id: get-pr
env:
GH_TOKEN: ${{ github.token }}
run: |
head_branch=$(echo '${{ steps.find-run.outputs.data }}' | jq -r '.head_branch')
head_repo=$(echo '${{ steps.find-run.outputs.data }}' | jq -r '.head_repository.full_name')
if [[ "${head_branch}" != "" && "${head_repo}" != "" ]]; then
pr_number="$(gh pr view -R "${head_repo}" "${head_branch}" --json number -q '.number')"
else
pr_number=""
fi
if [[ "${pr_number}" != "" ]]; then
echo "This workflow run was for PR #${pr_number}."
else
echo "This workflow run was not for a PR."
fi
echo "pr_number=${pr_number}" >> "$GITHUB_OUTPUT"
- name: Download code coverage reports
if: steps.get-pr.outputs.pr_number != ''
uses: actions/download-artifact@v4
with:
name: codecov-reports
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
path: reports/

- name: Download performance reports
if: steps.get-pr.outputs.pr_number != ''
uses: actions/download-artifact@v4
with:
name: perf-reports
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
path: reports/

- name: Show published reports
if: steps.get-pr.outputs.pr_number != ''
run: |
ls -lR reports/
64 changes: 42 additions & 22 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ jobs:
exit ${result}
- name: "Publish test results"
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
test-results-*.xml
# - name: "Publish test results"
# uses: EnricoMi/publish-unit-test-result-action@v2
# if: always()
# with:
# files: |
# test-results-*.xml

- name: "Generate code coverage report"
uses: clearlyip/code-coverage-report-action@v4
Expand All @@ -108,12 +108,24 @@ jobs:
artifact_download_workflow_names: "CI"
filename: "codecov.xml"

- name: "Publish code coverage data to PR"
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ github.actor != 'dependabot[bot]' && steps.code_coverage_report.outputs.file != '' && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') }}
- name: "Upload code coverage report"
uses: actions/upload-artifact@v4
with:
name: codecov-reports
path: code-coverage-results.md

- name: "Upload event file"
uses: actions/upload-artifact@v4
with:
name: event-file
path: ${{ github.event_path }}

# - name: "Publish code coverage data to PR"
# uses: marocchino/sticky-pull-request-comment@v2
# if: ${{ github.actor != 'dependabot[bot]' && steps.code_coverage_report.outputs.file != '' && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') }}
# with:
# path: code-coverage-results.md

check:
name: "Source code checks"
runs-on: ubuntu-latest
Expand Down Expand Up @@ -189,17 +201,25 @@ jobs:
run: cargo bench --workspace -- --output-format bencher | tee benchmarks.txt
working-directory: main

- name: Compare benchmark results
uses: openpgpjs/github-action-pull-request-benchmark@v1
if: ${{ github.actor != 'dependabot[bot]' }}
- name: Upload performance results
uses: actions/upload-artifact@v4
with:
name: "Time benchmark"
tool: "cargo"
pr-benchmark-file-path: pr/benchmarks.txt
base-benchmark-file-path: main/benchmarks.txt
comment-always: true
alert-threshold: "130%"
fail-on-alert: false
fail-threshold: "150%"
# A token is needed to leave commit comments
github-token: ${{ secrets.GITHUB_TOKEN }}
name: perf-reports
path: |
pr/benchmarks.txt
main/benchmarks.txt
# - name: Compare benchmark results
# uses: openpgpjs/github-action-pull-request-benchmark@v1
# if: ${{ github.actor != 'dependabot[bot]' }}
# with:
# name: "Time benchmark"
# tool: "cargo"
# pr-benchmark-file-path: pr/benchmarks.txt
# base-benchmark-file-path: main/benchmarks.txt
# comment-always: true
# alert-threshold: "130%"
# fail-on-alert: false
# fail-threshold: "150%"
# # A token is needed to leave commit comments
# github-token: ${{ secrets.GITHUB_TOKEN }}
32 changes: 30 additions & 2 deletions .github/workflows/devcontainer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,40 @@ on:
- main
pull_request:
paths:
- '.devcontainer/**'
- ".devcontainer/**"

jobs:
build:
name: "Build and publish"
name: "Build devcontainer"
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pre-build dev container image
uses: devcontainers/[email protected]
with:
imageName: ghcr.io/reubeno/brush/devcontainer
imageTag: latest
cacheFrom: ghcr.io/reubeno/brush/devcontainer
push: never

build_and_publish:
name: "Build and publish devcontainer"
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand Down

0 comments on commit 308b9df

Please sign in to comment.