From b8a0ece5dfb006651cc7ef8e170c38d3ae42c656 Mon Sep 17 00:00:00 2001 From: Vo Van Nghia Date: Wed, 11 Dec 2024 13:11:40 +0100 Subject: [PATCH 1/3] ci: upload test report to codecov --- .github/workflows/main.yaml | 52 ++++++++++++++++++++++++++++++++++--- ci/docker/Dockerfile | 2 +- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 4d2032afa..cd2d24fe4 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -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 ${{ steps.build.outputs.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 || '' }} @@ -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 @@ -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 @@ -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 @@ -372,6 +389,15 @@ 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 + 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-windows: runs-on: windows-latest @@ -445,8 +471,17 @@ 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 + 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-macos: strategy: @@ -536,6 +571,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 upload-release: runs-on: ubuntu-latest diff --git a/ci/docker/Dockerfile b/ci/docker/Dockerfile index e0ee69879..aa5e1ba91 100644 --- a/ci/docker/Dockerfile +++ b/ci/docker/Dockerfile @@ -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 From 12090bd9955a3f76e031640f9bd8ac18a3b54fc1 Mon Sep 17 00:00:00 2001 From: Vo Van Nghia Date: Wed, 11 Dec 2024 13:16:00 +0100 Subject: [PATCH 2/3] typo --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index cd2d24fe4..74de6bbf3 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -154,7 +154,7 @@ jobs: 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 ${{ steps.build.outputs.target }} --profile ci --cargo-profile ${{ steps.build.outputs.profile }} --workspace + 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 || '' }} From 8b7d23abfab2c3b8e0385199a5358b3c28df77f8 Mon Sep 17 00:00:00 2001 From: Vo Van Nghia Date: Wed, 11 Dec 2024 13:19:08 +0100 Subject: [PATCH 3/3] typo --- .github/workflows/main.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 74de6bbf3..6a5fbe440 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -390,7 +390,6 @@ jobs: path: ${{ github.workspace }}/target/${{ steps.build.outputs.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 }} @@ -474,7 +473,6 @@ jobs: 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 - if: ${{ matrix.platform.command == 'cargo' }} uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} @@ -572,7 +570,6 @@ jobs: 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 }}