diff --git a/.github/workflows/check-and-lint.yaml b/.github/workflows/check-and-lint.yaml new file mode 100644 index 00000000..6eb45d48 --- /dev/null +++ b/.github/workflows/check-and-lint.yaml @@ -0,0 +1,55 @@ +on: + pull_request: + push: + branches: + - main + + +name: Check and Lint + +jobs: + check: + name: Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: check + + fmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - run: rustup component add rustfmt + - uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + components: clippy + override: true + - uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --all-features + name: Clippy Output diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index cfec6d82..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: CI - -on: - pull_request: - push: - branches: - - master - -jobs: - build: - strategy: - matrix: - platform: [ubuntu-latest, macos-latest, windows-latest] - fail-fast: false - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.57.0 - profile: minimal - override: true - components: rustfmt, clippy - - uses: actions-rs/cargo@v1.0.1 - name: Check format - with: - command: fmt - args: --all -- --check - - uses: actions-rs/cargo@v1.0.1 - name: Run clippy - with: - command: clippy - args: --all-targets --locked -- -D warnings - - uses: actions-rs/cargo@v1.0.1 - name: Run clippy (All features) - with: - command: clippy - args: --all-targets --locked --all-features -- -D warnings - - uses: actions-rs/cargo@v1.0.1 - name: Run tests - with: - command: test diff --git a/.github/workflows/release-cross.yml b/.github/workflows/release-cross.yml deleted file mode 100644 index 7d3d4ef0..00000000 --- a/.github/workflows/release-cross.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: CD Cross - -on: - release: - types: [ created ] - -jobs: - build: - strategy: - fail-fast: false - matrix: - target: [ "aarch64-unknown-linux-gnu", "armv7-unknown-linux-gnueabihf", "x86_64-unknown-linux-musl" ] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.57.0 - profile: minimal - default: true - override: true - target: ${{ matrix.target }} - components: rustfmt, clippy - - uses: actions-rs/cargo@v1.0.1 - name: Check format - with: - use-cross: true - command: fmt - args: --all -- --check - - uses: actions-rs/cargo@v1.0.1 - name: Run clippy - with: - command: clippy - use-cross: true - args: --all-targets --locked --target ${{matrix.target}} -- -D warnings - - uses: actions-rs/cargo@v1.0.1 - name: Run clippy (All features) - with: - command: clippy - use-cross: true - args: --locked --all-features --target ${{matrix.target}} -- -D warnings - - uses: actions-rs/cargo@v1.0.1 - name: Run tests - with: - command: test - use-cross: true - args: --target ${{matrix.target}} - - uses: actions-rs/cargo@v1.0.1 - name: Build - with: - command: build - use-cross: true - args: --release --all-features --target ${{matrix.target}} - - name: Rename Release - run: | - mkdir assets - FILENAME=topgrade-${{github.event.release.tag_name}}-${{matrix.target}} - mv target/${{matrix.target}}/release/topgrade assets - cd assets - tar --format=ustar -czf $FILENAME.tar.gz topgrade - rm topgrade - ls . - - name: Release - uses: softprops/action-gh-release@v1 - with: - files: assets/* diff --git a/.github/workflows/release-packaging.yaml b/.github/workflows/release-packaging.yaml new file mode 100644 index 00000000..5db6e1ba --- /dev/null +++ b/.github/workflows/release-packaging.yaml @@ -0,0 +1,27 @@ +on: + push: + branches: + - main + +name: Release Packaging + +jobs: + release: + name: Release Packaging + env: + PROJECT_NAME_UNDERSCORE: topgrade_rs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - name: Release Build + run: cargo build --release + - name: 'Upload Artifact' + uses: actions/upload-artifact@v2 + with: + name: ${{ env.PROJECT_NAME_UNDERSCORE }} + path: target/release/${{ env.PROJECT_NAME_UNDERSCORE }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index ed30643f..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: CD Native - -on: - release: - types: [ created ] - -jobs: - build: - strategy: - fail-fast: false - matrix: - platform: [ ubuntu-latest, macos-latest, windows-latest ] - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.57.0 - profile: minimal - override: true - components: rustfmt, clippy - - uses: actions-rs/cargo@v1.0.1 - name: Check format - with: - command: fmt - args: --all -- --check - - uses: actions-rs/cargo@v1.0.1 - name: Run clippy - with: - command: clippy - args: --all-targets --locked -- -D warnings - - uses: actions-rs/cargo@v1.0.1 - name: Run clippy (All features) - with: - command: clippy - args: --all-targets --locked --all-features -- -D warnings - - uses: actions-rs/cargo@v1.0.1 - name: Run tests - with: - command: test - - uses: actions-rs/cargo@v1.0.1 - name: Build - with: - command: build - args: --release --all-features - - name: Rename Release (Unix) - run: | - cargo install default-target - mkdir assets - FILENAME=topgrade-${{github.event.release.tag_name}}-$(default-target) - mv target/release/topgrade assets - cd assets - tar --format=ustar -czf $FILENAME.tar.gz topgrade - rm topgrade - ls . - if: ${{ matrix.platform != 'windows-latest' }} - shell: bash - - name: Rename Release (Windows) - run: | - cargo install default-target - mkdir assets - FILENAME=topgrade-${{github.event.release.tag_name}}-$(default-target) - mv target/release/topgrade.exe assets/topgrade.exe - cd assets - powershell Compress-Archive -Path * -Destination ${FILENAME}.zip - rm topgrade.exe - ls . - if: ${{ matrix.platform == 'windows-latest' }} - shell: bash - - name: Release - uses: softprops/action-gh-release@v1 - with: - files: assets/* diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 00000000..98bfa98a --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,56 @@ +on: + pull_request: + push: + branches: + - main + +name: Test with Code Coverage + +jobs: + test: + name: Test + env: + PROJECT_NAME_UNDERSCORE: topgrade_rs + CARGO_INCREMENTAL: 0 + RUSTFLAGS: -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort + RUSTDOCFLAGS: -Cpanic=abort + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + - name: Cache dependencies + uses: actions/cache@v2 + env: + cache-name: cache-dependencies + with: + path: | + ~/.cargo/.crates.toml + ~/.cargo/.crates2.json + ~/.cargo/bin + ~/.cargo/registry/index + ~/.cargo/registry/cache + target + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }} + - name: Generate test result and coverage report + run: | + cargo install cargo2junit grcov; + cargo test $CARGO_OPTIONS -- -Z unstable-options --format json | cargo2junit > results.xml; + zip -0 ccov.zip `find . \( -name "$PROJECT_NAME_UNDERSCORE*.gc*" \) -print`; + grcov ccov.zip -s . -t lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" -o lcov.info; + - name: Upload test results + uses: EnricoMi/publish-unit-test-result-action@v1 + with: + check_name: Test Results + github_token: ${{ secrets.GITHUB_TOKEN }} + files: results.xml + - name: Upload to CodeCov + uses: codecov/codecov-action@v1 + with: + # required for private repositories: + # token: ${{ secrets.CODECOV_TOKEN }} + files: ./lcov.info + fail_ci_if_error: true