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: upload test report to codecov #570

Merged
merged 3 commits into from
Dec 11, 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
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 All @@ -11,7 +11,7 @@
RUN apk add --update --no-cache ca-certificates
RUN update-ca-certificates

FROM ${BASE_IMAGE}

Check warning on line 14 in ci/docker/Dockerfile

View workflow job for this annotation

GitHub Actions / build-docker

Default value for global ARG results in an empty or invalid base image name

InvalidDefaultArgInFrom: Default value for ARG ${BASE_IMAGE} results in empty or invalid base image name More info: https://docs.docker.com/go/dockerfile/rule/invalid-default-arg-in-from/

Check warning on line 14 in ci/docker/Dockerfile

View workflow job for this annotation

GitHub Actions / build-docker

Default value for global ARG results in an empty or invalid base image name

InvalidDefaultArgInFrom: Default value for ARG ${BASE_IMAGE} results in empty or invalid base image name More info: https://docs.docker.com/go/dockerfile/rule/invalid-default-arg-in-from/
COPY --from=artifact /artifact/nghe /app/nghe
COPY --from=artifact /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
ENV NGHE_SERVER__HOST="::"
Expand Down
Loading