Skip to content

Commit

Permalink
Refine workflows (#1778)
Browse files Browse the repository at this point in the history
* Refine workflows

* Include matrix.toolchain in job overview for test results

+ Use correct variable for continue-on-error for nightly

* Update test result handling

- Improves performance and structure for test result publishing
- Allows test results as PR comments not only for internal but also
  on fork PRs

* Enroll snap after build workflow
  • Loading branch information
ttytm committed Feb 27, 2023
1 parent fca70ce commit 3fbc937
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 31 deletions.
47 changes: 24 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,7 @@ defaults:

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Run rustfmt
run: cargo fmt --all --check

- name: Run clippy
run: cargo clippy -- -D warnings
uses: ./.github/workflows/lint-app.yml

test:
needs: lint
Expand All @@ -39,7 +30,7 @@ jobs:
os: [windows-latest, macOS-11, ubuntu-latest]
toolchain: [stable, nightly]
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.rust == 'nightly' }}
continue-on-error: ${{ matrix.toolchain == 'nightly' }}

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -75,18 +66,29 @@ jobs:
RUST_BACKTRACE: full
run: |
cargo nextest run --profile ci
mv target/nextest/ci/results.xml target/nextest/ci/results-${{ matrix.os }}.xml
- name: Prepare test results
run: |
mkdir -p test-results
mv target/nextest/ci/results-*.xml test-results/
- if: runner.os != 'Linux'
name: Publish test results for Windows and macOS
uses: EnricoMi/publish-unit-test-result-action/composite@v2
- name: Upload test results
uses: actions/upload-artifact@v3
with:
junit_files: target/nextest/ci/results.xml
name: test-results
path: |
test-results
- if: runner.os == 'Linux'
name: Publish test results for Linux
uses: EnricoMi/publish-unit-test-result-action@v2
event-upload:
needs: test
name: Upload Test Event
runs-on: ubuntu-latest
steps:
- uses: actions/upload-artifact@v3
with:
junit_files: target/nextest/ci/results.xml
name: test-event
path: ${{ github.event_path }}

build-deploy:
needs: test
Expand All @@ -99,8 +101,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Cargo cache
uses: actions/cache@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
Expand Down Expand Up @@ -192,7 +193,7 @@ jobs:
--icon-file=../../assets/neovide.svg \
--output=appimage
find . -type f -name 'Neovide_(nvim)-*.AppImage' -exec mv {} neovide.AppImage \;
mv Neovide_\(nvim\)-*.AppImage neovide.AppImage
echo "ARTIFACT=neovide-linux-x86_64.tar.gz" >> $GITHUB_ENV
echo "ARTIFACT2=neovide.AppImage" >> $GITHUB_ENV
Expand All @@ -203,7 +204,7 @@ jobs:
name: ${{ env.ARTIFACT }}
path: target/release/${{ env.ARTIFACT }}

- if: runner.os != 'macOS'
- if: env.ARTIFACT2
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT2 }}
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/lint-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ permissions:
contents: read

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_call:
Expand All @@ -29,6 +27,16 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- uses: giraffate/clippy-action@v1
with:
reporter: "github-pr-review"
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/snap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ permissions:
contents: read

on:
push:
branches: [main]
paths-ignore:
- "website/**"
- ".vscode/**"
- "**.md"
workflow_run:
workflows: [Build and Test]
types: [completed]

jobs:
snap:
runs-on: ubuntu-20.04
if: github.event.workflow_run.conclusion == 'success'

steps:
- name: Check out Git repository
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/test-results.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test Results

on:
workflow_run:
workflows: [Build and Test]
types: [completed]
permissions: {}

jobs:
Publish:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion != 'skipped'

permissions:
checks: write
pull-requests: write
actions: read

steps:
- name: Download and extract artifacts
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
mkdir -p artifacts && cd artifacts
artifacts_url=${{ github.event.workflow_run.artifacts_url }}
gh api --paginate "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact
do
IFS=$'\t' read name url <<< "$artifact"
gh api $url > "$name.zip"
unzip -d "$name" "$name.zip"
done
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
commit: ${{ github.event.workflow_run.head_sha }}
event_file: artifacts/test-event/event.json
event_name: ${{ github.event.workflow_run.event }}
files: "artifacts/**/*.xml"

0 comments on commit 3fbc937

Please sign in to comment.