Skip to content

Discard invalid tasks (#387) #1559

Discard invalid tasks (#387)

Discard invalid tasks (#387) #1559

Workflow file for this run

# name: Generate codegen diff
# on:
# pull_request:
# paths:
# - "codegenerator/**"
# - "scenarios/test_codegen/**"
# defaults:
# run:
# working-directory: scenarios/test_codegen
# env:
# CARGO_TERM_COLOR: always
# jobs:
# get_codegen_diff:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Setup rust cache
# uses: actions/cache@v3
# with:
# path: |
# ~/.cargo/git
# ~/.cargo/bin/
# ~/.cargo/registry/index/
# ~/.cargo/registry/cache/
# ~/.cargo/git/db/
# # using both of these paths to hedge bets on which is correct.
# ./codegenerator/target
# ./target
# key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# restore-keys: |
# ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# ${{ runner.os }}-cargo-
# - uses: pnpm/action-setup@v3
# with:
# version: 8.9
# - name: Get pnpm store directory (if this seems stable and static we can hard-code it again) # Source: https://github.com/pnpm/action-setup#use-cache-to-reduce-installation-time
# id: pnpm-cache
# shell: bash
# run: |
# echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
# - uses: actions/cache@v3
# name: Setup pnpm cache
# with:
# path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
# key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
# restore-keys: |
# ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
# ${{ runner.os }}-pnpm-store-
# - name: Get commit hash
# id: gethash
# run: echo "::set-output name=hash::$(git rev-parse --short "$GITHUB_SHA")"
# - name: Run envio codegen
# run: pnpm codegen
# - name: Setup Git
# run: |
# git config --global user.name "Codegen Bot Beep Boop"
# git config --global user.email "[email protected]"
# - name: Authenticate with GitHub
# env:
# GH_PAT: ${{ secrets.GH_PAT }}
# run: |
# echo "https://${GH_PAT}:[email protected]" > ~/.git-credentials
# git config --global credential.helper store
# - name: Get the branch name
# id: extract_branch
# run: |
# # ${{ github.head_ref || github.ref_name }} or ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} both work. `github.head_ref` doesn't work for direct pushes (not PRs).
# # Reference: https://stackoverflow.com/questions/60300169/how-to-get-branch-name-on-github-action
# echo "::set-output name=branch::$(echo ${{ github.head_ref || github.ref_name }})"
# - name: Commit and push changes to output repository
# id: git_push
# run: |
# git clone https://github.com/enviodev/test-codegen-output.git
# cd test-codegen-output
# git fetch origin
# if git branch -r | grep -q "origin/${{ steps.extract_branch.outputs.branch }}"; then
# git checkout ${{ steps.extract_branch.outputs.branch }}
# git pull origin ${{ steps.extract_branch.outputs.branch }}
# else
# git checkout -b ${{ steps.extract_branch.outputs.branch }}
# fi
# find . -not -name ".git" -not -name ".gitignore" -mindepth 1 -maxdepth 1 -exec rm -rf {} \;
# cp -r ../generated/* .
# git add -A
# if git diff --staged --quiet; then
# echo "No changes to commit"
# echo "::set-output name=no_changes::true"
# exit 0
# else
# git commit -m "Update based on commit ${{ steps.gethash.outputs.hash }} in parent repo"
# git push origin ${{ steps.extract_branch.outputs.branch }}
# echo "::set-output name=no_changes::false"
# fi
# - name: Get diff URL
# id: diff
# run: |
# cd test-codegen-output
# echo "::set-output name=url::https://github.com/enviodev/test-codegen-output/compare/$(git rev-parse main)...${{ steps.extract_branch.outputs.branch }}"
# - name: Comment PR
# uses: actions/github-script@v6
# with:
# script: |
# const issue_number = context.issue.number;
# const existing_comments = await github.rest.issues.listComments({
# owner: context.repo.owner,
# repo: context.repo.repo,
# issue_number: issue_number
# });
# const message = `Here's the [diff](${{ steps.diff.outputs.url }}) of the codegen output.πŸ™ŒπŸ§ πŸ¦œ`;
# // This goes through existing comments to make sure the comment is only made once.
# const existing_comment = existing_comments.data.find(comment => comment.body.includes(message));
# if (!existing_comment) {
# if (${{ steps.git_push.outputs.no_changes }} == "true") {
# github.rest.issues.createComment({
# owner: context.repo.owner,
# repo: context.repo.repo,
# issue_number: issue_number,
# body: "No changes detected to the codegen output. 🦜"
# });
# } else {
# github.rest.issues.createComment({
# owner: context.repo.owner,
# repo: context.repo.repo,
# issue_number: issue_number,
# body: message
# });
# }
# }