diff --git a/.github/workflows/auto-format.yml b/.github/workflows/auto-format.yml index 3865df5..c257dbb 100644 --- a/.github/workflows/auto-format.yml +++ b/.github/workflows/auto-format.yml @@ -27,18 +27,35 @@ jobs: - uses: actions/checkout@v4 with: ref: ${{ github.head_ref || github.ref_name }} + path: meta_plugin_protocol # Use PAT to trigger downstream workflows; fallback to GITHUB_TOKEN token: ${{ secrets.PARENT_REPO_PAT || github.token }} + - name: Create workspace Cargo.toml + run: | + cat > Cargo.toml << 'EOF' + [workspace] + members = ["meta_plugin_protocol"] + resolver = "2" + + [workspace.package] + version = "0.1.0" + edition = "2021" + license = "MIT" + repository = "https://github.com/harmony-labs/meta" + EOF + - uses: dtolnay/rust-toolchain@stable with: components: rustfmt - name: Run cargo fmt + working-directory: meta_plugin_protocol run: cargo fmt --all - name: Check for changes id: changes + working-directory: meta_plugin_protocol run: | if git diff --quiet; then echo "formatted=false" >> $GITHUB_OUTPUT @@ -48,6 +65,7 @@ jobs: - name: Commit and push if: steps.changes.outputs.formatted == 'true' + working-directory: meta_plugin_protocol run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00bbb0c..cbfc130 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,14 +20,34 @@ jobs: steps: - name: Checkout uses: actions/checkout@v6 + with: + path: meta_plugin_protocol + + - name: Create workspace Cargo.toml + shell: bash + run: | + cat > Cargo.toml << 'EOF' + [workspace] + members = ["meta_plugin_protocol"] + resolver = "2" + + [workspace.package] + version = "0.1.0" + edition = "2021" + license = "MIT" + repository = "https://github.com/harmony-labs/meta" + EOF - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - name: Cache Rust uses: Swatinem/rust-cache@v2 + with: + workspaces: meta_plugin_protocol - name: Run tests + working-directory: meta_plugin_protocol run: cargo test --all-features clippy: @@ -36,6 +56,22 @@ jobs: steps: - name: Checkout uses: actions/checkout@v6 + with: + path: meta_plugin_protocol + + - name: Create workspace Cargo.toml + run: | + cat > Cargo.toml << 'EOF' + [workspace] + members = ["meta_plugin_protocol"] + resolver = "2" + + [workspace.package] + version = "0.1.0" + edition = "2021" + license = "MIT" + repository = "https://github.com/harmony-labs/meta" + EOF - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable @@ -44,8 +80,11 @@ jobs: - name: Cache Rust uses: Swatinem/rust-cache@v2 + with: + workspaces: meta_plugin_protocol - name: Run clippy + working-directory: meta_plugin_protocol run: cargo clippy --all-targets --all-features -- -D warnings format: @@ -54,6 +93,22 @@ jobs: steps: - name: Checkout uses: actions/checkout@v6 + with: + path: meta_plugin_protocol + + - name: Create workspace Cargo.toml + run: | + cat > Cargo.toml << 'EOF' + [workspace] + members = ["meta_plugin_protocol"] + resolver = "2" + + [workspace.package] + version = "0.1.0" + edition = "2021" + license = "MIT" + repository = "https://github.com/harmony-labs/meta" + EOF - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable @@ -61,4 +116,5 @@ jobs: components: rustfmt - name: Check formatting + working-directory: meta_plugin_protocol run: cargo fmt --all -- --check diff --git a/.github/workflows/notify-downstream.yml b/.github/workflows/notify-downstream.yml new file mode 100644 index 0000000..13f8124 --- /dev/null +++ b/.github/workflows/notify-downstream.yml @@ -0,0 +1,65 @@ +name: Notify Downstream + +on: + push: + branches: [main] + +jobs: + wait-for-ci: + runs-on: ubuntu-latest + steps: + - name: Wait for CI + uses: lewagon/wait-on-check-action@v1.5.0 + with: + ref: ${{ github.sha }} + check-name: 'Test (ubuntu-latest)' + repo-token: ${{ secrets.GITHUB_TOKEN }} + wait-interval: 10 + + notify: + needs: wait-for-ci + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + downstream: + - meta_cli + - meta_git_cli + - meta_project_cli + - meta_rust_cli + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Extract commit info + id: commit + run: | + MSG=$(git log -1 --pretty=%s) + echo "message=$MSG" >> $GITHUB_OUTPUT + echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + if [[ "$MSG" =~ ^feat[:(] ]]; then echo "type=feat" >> $GITHUB_OUTPUT + elif [[ "$MSG" =~ ^fix[:(] ]]; then echo "type=fix" >> $GITHUB_OUTPUT + elif [[ "$MSG" =~ ^chore[:(] ]]; then echo "type=chore" >> $GITHUB_OUTPUT + elif [[ "$MSG" =~ ^docs[:(] ]]; then echo "type=docs" >> $GITHUB_OUTPUT + elif [[ "$MSG" =~ ^test[:(] ]]; then echo "type=test" >> $GITHUB_OUTPUT + elif [[ "$MSG" =~ ^refactor[:(] ]]; then echo "type=refactor" >> $GITHUB_OUTPUT + else echo "type=other" >> $GITHUB_OUTPUT + fi + + - name: Notify ${{ matrix.downstream }} + uses: peter-evans/repository-dispatch@v3 + with: + token: ${{ secrets.PARENT_REPO_PAT }} + repository: harmony-labs/${{ matrix.downstream }} + event-type: dependency-updated + client-payload: >- + { + "repo": ${{ toJSON(github.repository) }}, + "repo_name": ${{ toJSON(github.event.repository.name) }}, + "sha": ${{ toJSON(steps.commit.outputs.sha) }}, + "short_sha": ${{ toJSON(steps.commit.outputs.short_sha) }}, + "message": ${{ toJSON(steps.commit.outputs.message) }}, + "type": ${{ toJSON(steps.commit.outputs.type) }}, + "actor": ${{ toJSON(github.actor) }} + }