diff --git a/.github/actions/rust-env-setup/action.yml b/.github/actions/rust-env-setup/action.yml new file mode 100644 index 0000000000..42a011d5ec --- /dev/null +++ b/.github/actions/rust-env-setup/action.yml @@ -0,0 +1,36 @@ +name: "Prepare CI Rust environment" +description: "Installs rust, protoc, just, some other stuff too" +runs: + using: "composite" + steps: + - name: Install Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: clippy + rustflags: "" + cache: false + + - name: Setup Rust Caching + uses: WarpBuilds/rust-cache@v2 # a fork of Swatinem/rust-cache@v2 that uses warpbuild cache + with: + cache-on-failure: "true" + + - name: Install cargo-hakari + uses: taiki-e/install-action@v2 + with: + tool: cargo-hakari + + - name: Disable hakari + run: cargo hakari disable + shell: bash + + - name: Install protoc + uses: ./.github/actions/install-protoc + + - name: Install nextest + uses: taiki-e/install-action@v2 + with: + tool: nextest@0.9.98 + + - name: Setup just + uses: extractions/setup-just@v3 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 55f458ce5c..5443817148 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,38 +51,8 @@ jobs: - uses: actions/checkout@v4 - - name: Install Rust toolchain - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - components: clippy - rustflags: "" - cache: false - - - name: Setup Rust Caching - uses: WarpBuilds/rust-cache@v2 # a fork of Swatinem/rust-cache@v2 that uses warpbuild cache - with: - cache-on-failure: "true" - - - name: Install cargo-hakari - uses: taiki-e/install-action@v2 - with: - tool: cargo-hakari - - - name: Disable hakari - run: cargo hakari disable - - - name: Install protoc - uses: ./.github/actions/install-protoc - - - name: Install nextest - uses: taiki-e/install-action@v2 - with: - tool: nextest@0.9.98 - - - name: Setup just - uses: extractions/setup-just@v3 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Setup CI environment + uses: ./.github/actions/rust-env-setup - name: Check Cargo.lock file is updated run: cargo update -w --locked diff --git a/.github/workflows/fmt-slash-command.yml b/.github/workflows/fmt-slash-command.yml new file mode 100644 index 0000000000..95132139f3 --- /dev/null +++ b/.github/workflows/fmt-slash-command.yml @@ -0,0 +1,49 @@ +name: Fmt slash command +on: + repository_dispatch: + types: [fmt-command] +jobs: + pytest: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + token: ${{ secrets.PAT }} + repository: ${{ github.event.client_payload.github.payload.repository.full_name }} + ref: ${{ steps.vars.outputs.branch }} + + - name: Setup CI environment + uses: ./.github/actions/rust-env-setup + + - name: Run format + run: just fmt + + - name: Commit and push changes (if any) + shell: bash + env: + CI_COMMIT_MESSAGE: Update template + CI_COMMIT_AUTHOR: github-actions[bot] + CI_COMMIT_EMAIL: username@users.noreply.github.com + run: | + cd destination + git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}" + git config --global user.email "${{ env.CI_COMMIT_EMAIL }}" + if [[ `git status --porcelain --untracked-files=no` ]]; then + # Changes + git add . + git commit -m "${{ env.CI_COMMIT_MESSAGE }}" + git push + else + # No changes + echo "no changes to the destination" + exit 0 + fi + + # Add reaction to the comment + - name: Add reaction + uses: peter-evans/create-or-update-comment@v4 + with: + token: ${{ secrets.PAT }} + repository: ${{ github.event.client_payload.github.payload.repository.full_name }} + comment-id: ${{ github.event.client_payload.github.payload.comment.id }} + reactions: hooray \ No newline at end of file diff --git a/.github/workflows/rebase-slash-command.yml b/.github/workflows/rebase-slash-command.yml new file mode 100644 index 0000000000..06dba7ae38 --- /dev/null +++ b/.github/workflows/rebase-slash-command.yml @@ -0,0 +1,49 @@ +name: rebase-command +on: + repository_dispatch: + types: [rebase-command] +jobs: + rebase: + if: github.event.client_payload.pull_request.rebaseable == true + runs-on: ubuntu-latest + steps: + - name: Checkout pull request + uses: actions/checkout@v3 + with: + token: ${{ secrets.PAT }} + repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }} + ref: ${{ github.event.client_payload.pull_request.head.ref }} + fetch-depth: 0 + + - name: Rebase + run: | + git config --global user.name '${{ github.event.client_payload.github.actor }}' + git config --global user.email '${{ github.event.client_payload.github.actor }}@users.noreply.github.com' + git remote add base https://x-access-token:${{ secrets.PAT }}@github.com/${{ github.event.client_payload.pull_request.base.repo.full_name }}.git + git fetch base ${{ github.event.client_payload.pull_request.base.ref }} + git rebase base/${{ github.event.client_payload.pull_request.base.ref }} + git push --force-with-lease + + - name: Update comment + uses: peter-evans/create-or-update-comment@v4 + with: + token: ${{ secrets.PAT }} + repository: ${{ github.event.client_payload.github.payload.repository.full_name }} + comment-id: ${{ github.event.client_payload.github.payload.comment.id }} + body: | + >Pull request successfully rebased + reactions: hooray + + notRebaseable: + if: github.event.client_payload.pull_request.rebaseable != true + runs-on: ubuntu-latest + steps: + - name: Update comment + uses: peter-evans/create-or-update-comment@v4 + with: + token: ${{ secrets.PAT }} + repository: ${{ github.event.client_payload.github.payload.repository.full_name }} + comment-id: ${{ github.event.client_payload.github.payload.comment.id }} + body: | + >Pull request is not rebaseable + reactions: hooray \ No newline at end of file diff --git a/.github/workflows/slash-command-dispatch.yml b/.github/workflows/slash-command-dispatch.yml new file mode 100644 index 0000000000..4cf34b1d0f --- /dev/null +++ b/.github/workflows/slash-command-dispatch.yml @@ -0,0 +1,16 @@ +name: Slash Command Dispatch +on: + issue_comment: + types: [created] +jobs: + slashCommandDispatch: + runs-on: ubuntu-latest + steps: + - name: Slash Command Dispatch + uses: peter-evans/slash-command-dispatch@v4 + with: + token: ${{ secrets.PAT }} + commands: | + fmt + rebase +