From bb22c58be00e2bc49d6a0f2e45d7778ed8fc949e Mon Sep 17 00:00:00 2001 From: Naoaki Iwakiri Date: Mon, 23 Sep 2024 19:36:26 +0900 Subject: [PATCH] WIP --- .../install_required_cargo_bins/action.yaml | 26 +++++++ .github/actions/lint_format/action.yaml | 17 +++++ .github/workflows/basic_checks.yaml | 62 +++++++++++++++++ .github/workflows/beta_testing.yaml | 67 ++----------------- .github/workflows/continuous_testing.yaml | 25 ++----- .github/workflows/deployment_artifact.yaml | 31 ++------- 6 files changed, 121 insertions(+), 107 deletions(-) create mode 100644 .github/actions/install_required_cargo_bins/action.yaml create mode 100644 .github/actions/lint_format/action.yaml create mode 100644 .github/workflows/basic_checks.yaml 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..522f2e8 --- /dev/null +++ b/.github/actions/lint_format/action.yaml @@ -0,0 +1,17 @@ +name: 'Lint and Format' +description: "Lint and format check" +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..450f093 --- /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 + github_token: + type: string + 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: ${{ inputs.github_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..accd336 100644 --- a/.github/workflows/beta_testing.yaml +++ b/.github/workflows/beta_testing.yaml @@ -5,65 +5,12 @@ on: - cron: '3 1 * * 0' workflow_dispatch: push: - branches: - - master +# branches: +# - 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" + github_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..6d93ee8 100644 --- a/.github/workflows/continuous_testing.yaml +++ b/.github/workflows/continuous_testing.yaml @@ -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..edd870d 100644 --- a/.github/workflows/deployment_artifact.yaml +++ b/.github/workflows/deployment_artifact.yaml @@ -31,39 +31,18 @@ jobs: toolchain: stable profile: minimal 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: