diff --git a/.github/workflows/cache.yml b/.github/workflows/cache.yml new file mode 100644 index 00000000..adcdc459 --- /dev/null +++ b/.github/workflows/cache.yml @@ -0,0 +1,35 @@ +name: Caching Cargo events + +on: push + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Cache Cargo + id: cache-cargo + uses: actions/cache@v3 + env: + cache-name: cache-cargo + with: + path: cache-folder + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} + name: Install grcov + continue-on-error: true + run: cargo install grcov + + - name: Build + run: cargo build + + - name: Test + run: cargo test + + # TODO we need to pass the OS flags correctly \ No newline at end of file diff --git a/.github/workflows/publish-tests-results.yml b/.github/workflows/publish-tests-results.yml new file mode 100644 index 00000000..4253d472 --- /dev/null +++ b/.github/workflows/publish-tests-results.yml @@ -0,0 +1,37 @@ +name: Unit Test Results + +on: + workflow_run: + workflows: ["gcov"] + types: + - completed + +jobs: + unit-test-results: + name: Unit Test Results + runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion != 'skipped' + + 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 "$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 Unit Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + with: + commit: ${{ github.event.workflow_run.head_sha }} + event_file: artifacts/Event File/event.json + event_name: ${{ github.event.workflow_run.event }} + files: "artifacts/*.xml" \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 94192c97..b25eceeb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,82 +10,65 @@ env: CARGO_TERM_COLOR: always jobs: - # tests-unix: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - # - name: Run tests Unix - # working-directory: ./canyon_sql - # run: cargo test --verbose - - # tests-windows: - # runs-on: windows-latest - # steps: - # - uses: actions/checkout@v3 - # - name: Run tests for Windows - # working-directory: ./canyon_sql - # run: cargo test --verbose - - # tests-macos: - # runs-on: macos-latest - # steps: - # - uses: actions/checkout@v3 - # - name: Run tests for macOS - # working-directory: ./canyon_sql - # run: cargo test --verbose - gcov: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Use nightly toolchain - run: | - rustup toolchain install nightly - rustup override set nightly - - name: Run tests - env: - CARGO_INCREMENTAL: '0' - RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' - RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' - run: | - cargo test --all-features --no-fail-fast --target=x86_64-unknown-linux-gnu - - uses: actions-rs/grcov@v0.1 - # with: - # config: .github/workflows/configs/gcov-config.yml - - name: Generate code coverage report - if: always() - env: - CARGO_INCREMENTAL: '0' - RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' - RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' - run: | - grcov . -s . --binary-path ./target/debug/ -t cobertura --branch --ignore-not-existing -o ./target/debug/coverage - grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage - - - name: Publish Test Results - uses: EnricoMi/publish-unit-test-result-action@v2 - if: always() - with: - junit_files: "./target/debug/coverage" - - name: Upload Test Results - if: always() - uses: actions/upload-artifact@v2 - with: - name: Unit Test Results - path: | - ./target/debug/coverage/*.xml - - name: Show me directories - if: always() - run: | - ls -la ./target/debug - ls -la ./target/debug/coverage - - event_file: - name: "Event File" runs-on: ubuntu-latest steps: - - name: Upload - uses: actions/upload-artifact@v2 - with: - name: Event File - path: ${{ github.event_path }} \ No newline at end of file + - uses: actions/checkout@v3 + + - name: Use nightly toolchain + run: | + rustup toolchain install nightly + rustup override set nightly + + - name: Install grcov + run: cargo install grcov + + - name: Run tests + env: + CARGO_INCREMENTAL: '0' + RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' + RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' + run: | + cargo test --all-features --no-fail-fast --target=x86_64-unknown-linux-gnu + + - name: Generate code coverage report + if: always() + env: + CARGO_INCREMENTAL: '0' + RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' + RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' + run: | + grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage + grcov . -s . --binary-path ./target/debug/ -t cobertura --branch --ignore-not-existing -o ./target/debug/coverage/code_cov.xml + + - name: Publish Test Results from XML + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + junit_files: "./target/debug/coverage/code_cov.xml" + + - name: Show me directories + if: always() + run: | + ls -la ./target/debug + ls -la ./target/debug/coverage + ls -la ./target/debug/coverage/badges + + - name: Upload + uses: actions/upload-artifact@v3 + with: + name: Event File + path: ${{ github.event_path }} + - name: Publish Test Results + uses: actions/upload-artifact@v3 + with: + name: Unit Test Results + path: | + ./target/debug/coverage/code_cov.xml + ./target/debug/coverage/index.html + + - name: Publish coverage report to GitHub Pages + if: ${{ github.ref == 'refs/heads/main' }} + uses: JamesIves/github-pages-deploy-action@v4 + with: + folder: ./target/debug/coverage \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index cab6d0db..85971f6b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,5 @@ # This is the root Cargo.toml file that serves as manager for the workspace of the project -[profile.dev] -panic = "abort" - [workspace] members = [