From 81d0c030c048c16bacb3dc7c0d9be1ec2c3fd404 Mon Sep 17 00:00:00 2001 From: mslxl Date: Tue, 19 Mar 2024 23:31:06 +0800 Subject: [PATCH] chore(workflow): add ability to trigger tests on PR with specific comment (#31) --- .github/workflows/build-on-pr-comment.yml | 51 +++++++++++++++++++++++ .github/workflows/test-on-pr.yml | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-on-pr-comment.yml diff --git a/.github/workflows/build-on-pr-comment.yml b/.github/workflows/build-on-pr-comment.yml new file mode 100644 index 0000000..6b176c8 --- /dev/null +++ b/.github/workflows/build-on-pr-comment.yml @@ -0,0 +1,51 @@ +name: "test-on-pr-issue" +on: + issue_comment: + types: [created] + +jobs: + test-tauri: + if: github.event.issue.pull_request && (contains(github.event.comment.body, '/test') || contains(github.event.comment.body, '/build')) + strategy: + fail-fast: true + matrix: + platform: [macos-latest, ubuntu-20.04, windows-latest] + + runs-on: ${{ matrix.platform }} + steps: + - uses: xt0rted/pull-request-comment-branch@v2 + id: comment-branch + - uses: actions/checkout@v3 + if: success() + with: + ref: ${{ steps.comment-branch.outputs.head_ref }} + - name: setup node + uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install frontend dependencies + uses: pnpm/action-setup@v2 + with: + version: 8 + run_install: true + - name: install Rust stable + uses: dtolnay/rust-toolchain@stable + - name: install dependencies (ubuntu only) + if: matrix.platform == 'ubuntu-20.04' + run: | + sudo apt-get update + sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf + - name: Rust cache + uses: swatinem/rust-cache@v2 + with: + workspaces: "./src-tauri -> target" + - uses: tauri-apps/tauri-action@v0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/upload-artifact@v4 + with: + name: bundle + path: src-tauri/target/release/bundle/**/* + if-no-files-found: error + retention-days: 7 + compression-level: 9 \ No newline at end of file diff --git a/.github/workflows/test-on-pr.yml b/.github/workflows/test-on-pr.yml index 0c3bca0..3997642 100644 --- a/.github/workflows/test-on-pr.yml +++ b/.github/workflows/test-on-pr.yml @@ -33,4 +33,4 @@ jobs: workspaces: "./src-tauri -> target" - uses: tauri-apps/tauri-action@v0 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file