diff --git a/.github/actions/install_required_cargo_bins/action.yaml b/.github/actions/install_required_cargo_bins/action.yaml new file mode 100644 index 0000000..02737b0 --- /dev/null +++ b/.github/actions/install_required_cargo_bins/action.yaml @@ -0,0 +1,26 @@ +name: 'Install required cargo binaries' +description: "install cargo binaries to build C ABI library. Requires cargo installed before use." +runs: + using: "composite" + steps: + - name: Check rustup toolchain + run: rustup default + shell: bash + - name: cbindgen-exists + id: cbindgenCheck + run: test -e ~/.cargo/bin/cbindgen + continue-on-error: true + shell: bash + - name: Install cbindgen + if: ${{ always() && steps.cbindgenCheck.outcome == 'failure' }} + run: cargo +stable install cbindgen + shell: bash + - name: cargo-c-exists + id: cargoCCheck + run: test -e ~/.cargo/bin/cargo-cbuild + continue-on-error: true + shell: bash + - name: Install cargo-c + if: ${{ always() && steps.cargoCCheck.outcome == 'failure' }} + run: cargo +stable install cargo-c --version 0.9.12 + shell: bash \ No newline at end of file diff --git a/.github/actions/lint_format/action.yaml b/.github/actions/lint_format/action.yaml new file mode 100644 index 0000000..2aff328 --- /dev/null +++ b/.github/actions/lint_format/action.yaml @@ -0,0 +1,17 @@ +name: 'Lint and Format' +description: "Lint and format check. Requires cargo, rustfmt and clippy installed before use." +inputs: + github_token: + description: 'github token' + required: true +runs: + using: "composite" + steps: + - name: Format check + run: cargo fmt -- --check + shell: bash + - name: Lint check + uses: giraffate/clippy-action@v1 + with: + github_token: ${{ inputs.github_token }} + clippy_flags: -- -D warnings -A dead_code -A improper_ctypes_definitions \ No newline at end of file diff --git a/.github/workflows/basic_checks.yaml b/.github/workflows/basic_checks.yaml new file mode 100644 index 0000000..b1e75f4 --- /dev/null +++ b/.github/workflows/basic_checks.yaml @@ -0,0 +1,62 @@ +# Only check that build passes +name: Basic check +on: + workflow_call: + inputs: + toolchain: + type: string + required: true + secrets: + gh_token: + required: true + +jobs: + lint: + name: lint and format check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ inputs.toolchain }} + - name: Install cargo + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: ${{ inputs.toolchain }} + components: rustfmt, clippy + rustflags: "" + override: true + - name: Lint and format + uses: ./.github/actions/lint_format + with: + github_token: ${{ secrets.gh_token }} + rust_test: + name: cargo test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ inputs.toolchain }} + - name: Install required libs (Ubuntu) + run: sudo apt-get install libxkbcommon-dev + - name: Install cargo + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: ${{ inputs.toolchain }} + rustflags: "" + override: true + - name: Run rust test + run: cargo test --features capi \ No newline at end of file diff --git a/.github/workflows/beta_testing.yaml b/.github/workflows/beta_testing.yaml index 55a8937..87b55d0 100644 --- a/.github/workflows/beta_testing.yaml +++ b/.github/workflows/beta_testing.yaml @@ -9,61 +9,9 @@ on: - master jobs: - lint: - name: lint and format check - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-beta - - name: Install cargo - uses: actions-rs/toolchain@v1 - with: - toolchain: beta - profile: minimal - components: rustfmt, clippy - override: true - - name: Format check - uses: actions-rs/cargo@v1 - with: - command: fmt - args: -- --check - - name: Lint check - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: -- -D warnings -A dead_code -A improper_ctypes_definitions - rust_test: - name: cargo test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-beta - - name: Install required libs (Ubuntu) - run: sudo apt-get install libxkbcommon-dev - - name: Install cargo - uses: actions-rs/toolchain@v1 - with: - toolchain: beta - profile: minimal - override: true - - name: Run rust test - uses: actions-rs/cargo@v1 - with: - command: test - args: --features capi \ No newline at end of file + basic_check: + uses: ./.github/workflows/basic_checks.yaml + with: + toolchain: "beta" + secrets: + gh_token: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file diff --git a/.github/workflows/continuous_testing.yaml b/.github/workflows/continuous_testing.yaml index 82a1745..c37aad2 100644 --- a/.github/workflows/continuous_testing.yaml +++ b/.github/workflows/continuous_testing.yaml @@ -1,4 +1,4 @@ -name: Test +name: Continuous branch tests before merge on: [push, workflow_dispatch] concurrency: @@ -27,13 +27,10 @@ jobs: components: rustfmt, clippy rustflags: "" override: true - - name: Format check - run: cargo fmt -- --check - - name: Lint check - uses: giraffate/clippy-action@v1 + - name: Lint and format + uses: ./.github/actions/lint_format with: github_token: ${{ secrets.GITHUB_TOKEN }} - clippy_flags: -- -D warnings -A dead_code -A improper_ctypes_definitions rust_test: name: cargo test strategy: @@ -93,22 +90,8 @@ jobs: ~/.cargo/git/db/ target key: ${{ runner.os }}-cargo-libtest-v6-${{ hashFiles('**/Cargo.lock') }}-cargo-c-v0.9.6 - - name: Check rustup toolchain - run: rustup default - - name: cbindgen-exists - id: cbindgenCheck - run: test -e ~/.cargo/bin/cbindgen - continue-on-error: true - - name: Install cbindgen - if: ${{ always() && steps.cbindgenCheck.outcome == 'failure' }} - run: cargo +stable install cbindgen - - name: cargo-c-exists - id: cargoCCheck - run: test -e ~/.cargo/bin/cargo-cbuild - continue-on-error: true - - name: Install cargo-c - if: ${{ always() && steps.cargoCCheck.outcome == 'failure' }} - run: cargo +stable install cargo-c --version 0.9.12 + - name: Install required rust tools + uses: ./.github/actions/install_required_cargo_bins - name: Install required libs (Ubuntu) if: matrix.os == 'ubuntu-latest' run: sudo apt-get install libxkbcommon-dev diff --git a/.github/workflows/deployment_artifact.yaml b/.github/workflows/deployment_artifact.yaml index c79398c..f57c59b 100644 --- a/.github/workflows/deployment_artifact.yaml +++ b/.github/workflows/deployment_artifact.yaml @@ -26,44 +26,23 @@ jobs: run: | grep -F "[${{ steps.versions.outputs.version }}]" CHANGELOG.md - name: Install cargo - uses: actions-rs/toolchain@v1 + uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: stable - profile: minimal + toolchain: ${{ inputs.toolchain }} + rustflags: "" override: true - - name: Install cbindgen - uses: actions-rs/cargo@v1 - with: - command: install - args: cbindgen - - name: cargo-c-exists - id: cargoCCheck - run: test -e ~/.cargo/bin/cargo-cbuild - continue-on-error: true - - name: Install cargo-c - if: ${{ always() && steps.cargoCCheck.outcome == 'failure' }} - uses: actions-rs/cargo@v1 - with: - command: install - args: cargo-c + - name: Install required rust tools + uses: .github/actions/install_required_cargo_bins - name: Install required libs (Ubuntu) run: sudo apt-get install libxkbcommon-dev - name: Build library - uses: actions-rs/cargo@v1 - with: - command: cbuild - args: --release + run: cargo cbuild --release - name: Build symbolic links run: bin/generate_deb_symlinks.sh - name: Install cargo-deb - uses: actions-rs/cargo@v1 - with: - command: install - args: cargo-deb + run: cargo install cargo-deb --force - name: Prepare deb file - uses: actions-rs/cargo@v1 - with: - command: deb + run: cargo deb - name: Upload release artifact uses: softprops/action-gh-release@v1 with: diff --git a/.github/workflows/nightly_testing.yaml b/.github/workflows/nightly_testing.yaml index 1446c8b..f555da5 100644 --- a/.github/workflows/nightly_testing.yaml +++ b/.github/workflows/nightly_testing.yaml @@ -6,61 +6,9 @@ on: workflow_dispatch: jobs: - lint: - name: lint and format check - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-nightly - - name: Install cargo - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - profile: minimal - components: rustfmt, clippy - override: true - - name: Format check - uses: actions-rs/cargo@v1 - with: - command: fmt - args: -- --check - - name: Lint check - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: -- -D warnings -A dead_code -A improper_ctypes_definitions - rust_test: - name: cargo test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-nightly - - name: Install required libs (Ubuntu) - run: sudo apt-get install libxkbcommon-dev - - name: Install cargo - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - profile: minimal - override: true - - name: Run rust test - uses: actions-rs/cargo@v1 - with: - command: test - args: --features capi \ No newline at end of file + basic_check: + uses: ./.github/workflows/basic_checks.yaml + with: + toolchain: "nightly" + secrets: + gh_token: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file diff --git a/.github/workflows/stable_testing.yaml b/.github/workflows/stable_testing.yaml index 3f80f0c..f6977db 100644 --- a/.github/workflows/stable_testing.yaml +++ b/.github/workflows/stable_testing.yaml @@ -1,4 +1,4 @@ -name: Stable +name: Stable Test # On every Sunday at 02:03 on: schedule: @@ -9,61 +9,9 @@ on: - master jobs: - lint: - name: lint and format check - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-beta - - name: Install cargo - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - components: rustfmt, clippy - override: true - - name: Format check - uses: actions-rs/cargo@v1 - with: - command: fmt - args: -- --check - - name: Lint check - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: -- -D warnings -A dead_code -A improper_ctypes_definitions - rust_test: - name: cargo test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-beta - - name: Install required libs (Ubuntu) - run: sudo apt-get install libxkbcommon-dev - - name: Install cargo - uses: actions-rs/toolchain@v1 - with: - toolchain: beta - profile: minimal - override: true - - name: Run rust test - uses: actions-rs/cargo@v1 - with: - command: test - args: --features capi \ No newline at end of file + basic_check: + uses: ./.github/workflows/basic_checks.yaml + with: + toolchain: "stable" + secrets: + gh_token: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file