From c481be00280ca63df3e296273242c72d96cac994 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 17 Sep 2024 11:49:51 -0400 Subject: [PATCH] ci: move Archaeologist to GHA (#43734) * chore: move Archaeologist to GHA Co-authored-by: John Kleinschmidt * chore: test archaelogist changes Co-authored-by: John Kleinschmidt * Revert "chore: test archaelogist changes" This reverts commit a575d6ef3a6495a71c03e9e2d15ec9bb329c5033. Co-authored-by: John Kleinschmidt * chore: properly name steps in archaeologist-dig Co-authored-by: John Kleinschmidt --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: John Kleinschmidt --- .github/actions/generate-types/action.yml | 24 +++++++++ .github/workflows/archaeologist-dig.yml | 61 +++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 .github/actions/generate-types/action.yml create mode 100644 .github/workflows/archaeologist-dig.yml diff --git a/.github/actions/generate-types/action.yml b/.github/actions/generate-types/action.yml new file mode 100644 index 00000000000..9909fba912c --- /dev/null +++ b/.github/actions/generate-types/action.yml @@ -0,0 +1,24 @@ +name: 'Generate Types for Archaeologist Dig' +description: 'Generate Types for Archaeologist Dig' +inputs: + sha-file: + description: 'File containing sha' + required: true + filename: + description: 'Filename to write types to' + required: true +runs: + using: "composite" + steps: + - name: Generating Types for SHA in ${{ inputs.sha-file }} + shell: bash + run: | + git checkout $(cat ${{ inputs.sha-file }}) + rm -rf node_modules + yarn install --frozen-lockfile --ignore-scripts + echo "#!/usr/bin/env node\nglobal.x=1" > node_modules/typescript/bin/tsc + node node_modules/.bin/electron-docs-parser --dir=./ --outDir=./ --moduleVersion=0.0.0-development + node node_modules/.bin/electron-typescript-definitions --api=electron-api.json --outDir=artifacts + mv artifacts/electron.d.ts artifacts/${{ inputs.filename }} + git checkout . + working-directory: ./electron diff --git a/.github/workflows/archaeologist-dig.yml b/.github/workflows/archaeologist-dig.yml new file mode 100644 index 00000000000..08ca923d0e9 --- /dev/null +++ b/.github/workflows/archaeologist-dig.yml @@ -0,0 +1,61 @@ +name: Archaeologist + +on: + pull_request: + +jobs: + archaeologist-dig: + name: Archaeologist Dig + runs-on: ubuntu-latest + steps: + - name: Checkout Electron + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.0.2 + with: + fetch-depth: 0 + - name: Setting Up Dig Site + run: | + echo "remote: ${{ github.event.pull_request.head.repo.clone_url }}" + echo "sha ${{ github.event.pull_request.head.sha }}" + echo "base ref ${{ github.event.pull_request.base.ref }}" + git clone https://github.com/electron/electron.git electron + cd electron + mkdir -p artifacts + git remote add fork ${{ github.event.pull_request.head.repo.clone_url }} && git fetch fork + git checkout ${{ github.event.pull_request.head.sha }} + git merge-base origin/${{ github.event.pull_request.base.ref }} HEAD > .dig-old + echo ${{ github.event.pull_request.head.sha }} > .dig-new + cp .dig-old artifacts + + - name: Generating Types for SHA in .dig-new + uses: ./.github/actions/generate-types + with: + sha-file: .dig-new + filename: electron.new.d.ts + - name: Generating Types for SHA in .dig-old + uses: ./.github/actions/generate-types + with: + sha-file: .dig-old + filename: electron.old.d.ts + - name: Upload artifacts + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 #v4.4.0 + with: + name: artifacts + path: electron/artifacts + include-hidden-files: true + - name: Set job output + run: | + git diff --no-index electron.old.d.ts electron.new.d.ts > patchfile || true + if [ -s patchfile ]; then + echo "Changes Detected" + echo "## Changes Detected" > $GITHUB_STEP_SUMMARY + echo "Looks like the \`electron.d.ts\` file changed." >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`\`\`\`diff" >> $GITHUB_STEP_SUMMARY + cat patchfile >> $GITHUB_STEP_SUMMARY + echo "\`\`\`\`\`\`" >> $GITHUB_STEP_SUMMARY + else + echo "No Changes Detected" + echo "## No Changes" > $GITHUB_STEP_SUMMARY + echo "We couldn't see any changes in the \`electron.d.ts\` artifact" >> $GITHUB_STEP_SUMMARY + fi + working-directory: ./electron/artifacts