Skip to content

Commit

Permalink
ci: upload test report to codecov (#570)
Browse files Browse the repository at this point in the history
* ci: upload test report to codecov

* typo

* typo
  • Loading branch information
vnghia authored Dec 11, 2024
1 parent 593d70b commit bcb0ba3
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
49 changes: 45 additions & 4 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,18 @@ jobs:
rev: 19be83481fd3e50ea103d800d72e0f8eddb1c90c
locked: false

- name: Install cargo-nextest
if: ${{ matrix.platform.command == 'cargo' }}
uses: taiki-e/install-action@nextest

- name: Build and test
run: |
${{ matrix.platform.command }} build --locked --target ${{ matrix.platform.target }} --profile ${{ steps.build.outputs.profile }}
${{ matrix.platform.command }} test --locked --target ${{ matrix.platform.target }} --profile ${{ steps.build.outputs.profile }} --workspace --exclude nghe-frontend
if [[ ${{ matrix.platform.command }} == 'cross' ]]; then
cross test --locked --target ${{ matrix.platform.target }} --profile ${{ steps.build.outputs.profile }} --workspace
else
cargo nextest run --locked --target ${{ matrix.platform.target }} --profile ci --cargo-profile ${{ steps.build.outputs.profile }} --workspace
fi
env:
LASTFM_KEY: ${{ steps.build.outputs.docker-arch == 'amd64' && secrets.LASTFM_KEY || '' }}
SPOTIFY_ID: ${{ steps.build.outputs.docker-arch == 'amd64' && secrets.SPOTIFY_ID || '' }}
Expand All @@ -158,6 +166,15 @@ jobs:
name: ${{ steps.build.outputs.docker-arch }}-${{ steps.build.outputs.env }}
path: ${{ github.workspace }}/target/${{ matrix.platform.target }}/${{ steps.build.outputs.output-dir }}/nghe_backend
retention-days: 1
- name: Upload test report to Codecov
if: ${{ matrix.platform.command == 'cargo' }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: target/nextest/ci/junit.xml
disable_search: true
report_type: "test_results"
fail_ci_if_error: true

build-docker:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -201,7 +218,7 @@ jobs:
context: .
file: ci/docker/Dockerfile
build-args: |
BASE_IMAGE=debian:12.5-slim
BASE_IMAGE=debian:12.8-slim
TARGET_ENV=gnu
platforms: linux/amd64,linux/arm64
push: true
Expand All @@ -224,7 +241,7 @@ jobs:
context: .
file: ci/docker/Dockerfile
build-args: |
BASE_IMAGE=alpine:3.19.1
BASE_IMAGE=alpine:3.21.0
TARGET_ENV=musl
platforms: linux/amd64,linux/arm64
push: true
Expand Down Expand Up @@ -372,6 +389,14 @@ jobs:
name: amd64-${{ steps.build.outputs.env }}-${{ matrix.version }}
path: ${{ github.workspace }}/target/${{ steps.build.outputs.target }}/${{ steps.build.outputs.output-dir }}/nghe_backend
retention-days: 1
- name: Upload test report to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: target/nextest/ci/junit.xml
disable_search: true
report_type: "test_results"
fail_ci_if_error: true

build-windows:
runs-on: windows-latest
Expand Down Expand Up @@ -445,8 +470,16 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: amd64-windows
path: ${{ github.workspace }}\target\x86_64-pc-windows-msvc\${{ steps.build.outputs.output-dir }}\nghe.exe
path: ${{ github.workspace }}\target\x86_64-pc-windows-msvc\${{ steps.build.outputs.output-dir }}\nghe_backend.exe
retention-days: 1
- name: Upload test report to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: target\nextest\ci\junit.xml
disable_search: true
report_type: "test_results"
fail_ci_if_error: true

build-macos:
strategy:
Expand Down Expand Up @@ -536,6 +569,14 @@ jobs:
name: ${{ steps.build.outputs.docker-arch }}-${{ steps.build.outputs.env }}
path: ${{ github.workspace }}/target/${{ matrix.platform.target }}/${{ steps.build.outputs.output-dir }}/nghe_backend
retention-days: 1
- name: Upload test report to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: target/nextest/ci/junit.xml
disable_search: true
report_type: "test_results"
fail_ci_if_error: true

upload-release:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion ci/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG BASE_IMAGE

FROM --platform=${BUILDPLATFORM} alpine as artifact
FROM --platform=${BUILDPLATFORM} alpine AS artifact
COPY artifact/ /artifact/
ARG TARGET_ENV
ARG TARGETARCH
Expand Down

0 comments on commit bcb0ba3

Please sign in to comment.