Skip to content

Commit

Permalink
ci: run nextest for cross build (#571)
Browse files Browse the repository at this point in the history
* ci: run nextest for cross build

* backend/time: sleep a little bit more

* typo

* typo

* upload

* upload even if failure
  • Loading branch information
vnghia authored Dec 11, 2024
1 parent bcb0ba3 commit fcd6b0f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 33 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,20 @@ jobs:
LASTFM_KEY: ${{ secrets.LASTFM_KEY }}
SPOTIFY_ID: ${{ secrets.SPOTIFY_ID }}
SPOTIFY_SECRET: ${{ secrets.SPOTIFY_SECRET }}
- name: Upload coverage to Codecov
- name: Upload test report to Codecov
if: success() || failure()
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: codecov.json
files: target/nextest/ci/junit.xml
disable_search: true
report_type: "coverage"
report_type: "test_results"
fail_ci_if_error: true
- name: Upload test report to Codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: target/nextest/ci/junit.xml
files: codecov.json
disable_search: true
report_type: "test_results"
report_type: "coverage"
fail_ci_if_error: true
55 changes: 29 additions & 26 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,29 +152,29 @@ jobs:
run: |
${{ matrix.platform.command }} build --locked --target ${{ matrix.platform.target }} --profile ${{ steps.build.outputs.profile }}
if [[ ${{ matrix.platform.command }} == 'cross' ]]; then
cross test --locked --target ${{ matrix.platform.target }} --profile ${{ steps.build.outputs.profile }} --workspace
cross-util run --target ${{ matrix.platform.target }} -- '/usr/bin/cargo-nextest nextest run --locked --target ${{ matrix.platform.target }} --profile ci --cargo-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 || '' }}
SPOTIFY_SECRET: ${{ steps.build.outputs.docker-arch == 'amd64' && secrets.SPOTIFY_SECRET || '' }}
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
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' }}
if: success() || failure()
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
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
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

build-docker:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -383,20 +383,21 @@ jobs:
cargo build --locked --target ${{ steps.build.outputs.target }} --profile ${{ steps.build.outputs.profile }}
cargo nextest run --locked --target ${{ steps.build.outputs.target }} --profile ci --cargo-profile ${{ steps.build.outputs.profile }} --workspace
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
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: success() || failure()
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
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
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

build-windows:
runs-on: windows-latest
Expand Down Expand Up @@ -466,20 +467,21 @@ jobs:
LASTFM_KEY: ${{ secrets.LASTFM_KEY }}
SPOTIFY_ID: ${{ secrets.SPOTIFY_ID }}
SPOTIFY_SECRET: ${{ secrets.SPOTIFY_SECRET }}
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: amd64-windows
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: success() || failure()
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
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: amd64-windows
path: ${{ github.workspace }}\target\x86_64-pc-windows-msvc\${{ steps.build.outputs.output-dir }}\nghe_backend.exe
retention-days: 1

build-macos:
strategy:
Expand Down Expand Up @@ -563,20 +565,21 @@ jobs:
LASTFM_KEY: ${{ steps.build.outputs.docker-arch == 'arm64' && secrets.LASTFM_KEY || '' }}
SPOTIFY_ID: ${{ steps.build.outputs.docker-arch == 'arm64' && secrets.SPOTIFY_ID || '' }}
SPOTIFY_SECRET: ${{ steps.build.outputs.docker-arch == 'arm64' && secrets.SPOTIFY_SECRET || '' }}
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
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: success() || failure()
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
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
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

upload-release:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions ci/cross-pre-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ set -euxo pipefail
if [[ "$CROSS_TARGET" == "aarch64-unknown-linux-gnu" ]]; then
apt-get update && apt-get --assume-yes install libclang-10-dev
fi

curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C /usr/bin/
3 changes: 2 additions & 1 deletion nghe-backend/src/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::time::Duration;
pub async fn now() -> time::OffsetDateTime {
let now = time::OffsetDateTime::now_utc();
// Sleep one microsecond because that is the highest time precision postgresql can store.
tokio::time::sleep(Duration::from_micros(1)).await;
// In test, we will sleep a little bit more just to be sure.
tokio::time::sleep(Duration::from_micros(if cfg!(test) { 10 } else { 1 })).await;
now
}

0 comments on commit fcd6b0f

Please sign in to comment.