From 13a2150e8e67eccad6eec916dd3132ade5cdc3ad Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 2 Oct 2023 13:15:05 -0700 Subject: [PATCH] Speed up GHA workflows, use consistent bot token, etc (#55923) --- .../workflows/accept-baselines-fix-lints.yaml | 5 ++- .github/workflows/new-release-branch.yaml | 12 +++---- .github/workflows/rich-navigation.yml | 4 +-- .github/workflows/set-version.yaml | 8 ++--- .github/workflows/sync-branch.yaml | 14 ++++---- .github/workflows/twoslash-repros.yaml | 5 +-- .github/workflows/update-lkg.yml | 36 ------------------- .github/workflows/update-package-lock.yaml | 5 +-- 8 files changed, 23 insertions(+), 66 deletions(-) delete mode 100644 .github/workflows/update-lkg.yml diff --git a/.github/workflows/accept-baselines-fix-lints.yaml b/.github/workflows/accept-baselines-fix-lints.yaml index cc3f27235f5..c1478e5b1ec 100644 --- a/.github/workflows/accept-baselines-fix-lints.yaml +++ b/.github/workflows/accept-baselines-fix-lints.yaml @@ -16,11 +16,10 @@ jobs: build: runs-on: ubuntu-latest - permissions: - contents: write - steps: - uses: actions/checkout@v3 + with: + token: ${{ secrets.TS_BOT_GITHUB_TOKEN }} - uses: actions/setup-node@v3 - name: Configure Git, Run Tests, Update Baselines, Apply Fixes diff --git a/.github/workflows/new-release-branch.yaml b/.github/workflows/new-release-branch.yaml index 03026e711e5..1305a79506d 100644 --- a/.github/workflows/new-release-branch.yaml +++ b/.github/workflows/new-release-branch.yaml @@ -17,13 +17,12 @@ jobs: build: runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: - fetch-depth: 5 + filter: blob:none # https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ + fetch-depth: 0 # Default is 1; need to set to 0 to get the benefits of blob:none. + token: ${{ secrets.TS_BOT_GITHUB_TOKEN }} - uses: actions/setup-node@v3 - run: | npm --version @@ -38,10 +37,11 @@ jobs: sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/tsserverlibrary.d.ts sed -i -e 's/const version\(: string\)\{0,1\} = `${versionMajorMinor}.0-.*`/const version = `${versionMajorMinor}.0-${{ github.event.client_payload.core_tag || 'dev' }}`/g' src/compiler/corePublic.ts npm ci + npm install # update package-lock.json to ensure the version bump is included npx hereby LKG npm test git diff - git add package.json + git add package.json package-lock.json git add src/compiler/corePublic.ts git add tests/baselines/reference/api/typescript.d.ts git add tests/baselines/reference/api/tsserverlibrary.d.ts diff --git a/.github/workflows/rich-navigation.yml b/.github/workflows/rich-navigation.yml index 83bf30ec083..890bec4d63d 100644 --- a/.github/workflows/rich-navigation.yml +++ b/.github/workflows/rich-navigation.yml @@ -24,9 +24,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 5 + - uses: actions/checkout@v4 - uses: actions/setup-node@v3 diff --git a/.github/workflows/set-version.yaml b/.github/workflows/set-version.yaml index c641b03a17e..8e6a2439cc8 100644 --- a/.github/workflows/set-version.yaml +++ b/.github/workflows/set-version.yaml @@ -16,14 +16,11 @@ defaults: jobs: build: runs-on: ubuntu-latest - - permissions: - contents: write - steps: - uses: actions/checkout@v3 with: ref: ${{ github.event.client_payload.branch_name }} + token: ${{ secrets.TS_BOT_GITHUB_TOKEN }} - uses: actions/setup-node@v3 - run: | npm --version @@ -44,10 +41,11 @@ jobs: sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/tsserverlibrary.d.ts sed -i -e 's/const version\(: string\)\{0,1\} = .*;/const version = "${{ github.event.client_payload.package_version }}" as string;/g' src/compiler/corePublic.ts npm ci + npm install # update package-lock.json to ensure the version bump is included npx hereby LKG npm test git diff - git add package.json + git add package.json package-lock.json git add src/compiler/corePublic.ts git add tests/baselines/reference/api/typescript.d.ts git add tests/baselines/reference/api/tsserverlibrary.d.ts diff --git a/.github/workflows/sync-branch.yaml b/.github/workflows/sync-branch.yaml index 68dc6b286c4..190684e4607 100644 --- a/.github/workflows/sync-branch.yaml +++ b/.github/workflows/sync-branch.yaml @@ -22,16 +22,14 @@ jobs: build: runs-on: ubuntu-latest - permissions: - contents: write - steps: - uses: actions/setup-node@v3 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.event.inputs.branch_name || github.event.client_payload.branch_name }} - fetch-depth: 0 - # This does a test post-merge and only pushes the result if the test succeeds + filter: blob:none # https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ + fetch-depth: 0 # Default is 1; need to set to 0 to get the benefits of blob:none. + token: ${{ secrets.TS_BOT_GITHUB_TOKEN }} # required client_payload members: # branch_name - the target branch - run: | @@ -40,5 +38,7 @@ jobs: git fetch origin main git merge origin/main --no-ff npm ci - npm test + npx hereby LKG + git add --force ./lib + git commit -m 'Update LKG' git push diff --git a/.github/workflows/twoslash-repros.yaml b/.github/workflows/twoslash-repros.yaml index 60aba0dc60b..e2002cc11ef 100644 --- a/.github/workflows/twoslash-repros.yaml +++ b/.github/workflows/twoslash-repros.yaml @@ -34,9 +34,10 @@ jobs: runs-on: ubuntu-latest steps: - if: ${{ github.event.inputs.bisect }} - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - fetch-depth: 0 + filter: blob:none # https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ + fetch-depth: 0 # Default is 1; need to set to 0 to get the benefits of blob:none. - if: ${{ !github.event.inputs.bisect }} uses: actions/checkout@v3 - uses: actions/setup-node@v3 diff --git a/.github/workflows/update-lkg.yml b/.github/workflows/update-lkg.yml deleted file mode 100644 index c335f5a8d15..00000000000 --- a/.github/workflows/update-lkg.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Update LKG - -on: - workflow_dispatch: {} - -permissions: - contents: read - -# Ensure scripts are run with pipefail. See: -# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference -defaults: - run: - shell: bash - -jobs: - build: - runs-on: ubuntu-latest - - permissions: - contents: write - - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - - - name: Configure Git and Update LKG - run: | - git config user.email "typescriptbot@microsoft.com" - git config user.name "TypeScript Bot" - npm ci - npx hereby LKG - npm test - git diff - git add --force ./lib - git commit -m "Update LKG" - git push diff --git a/.github/workflows/update-package-lock.yaml b/.github/workflows/update-package-lock.yaml index da5796e9b0d..ce903424c80 100644 --- a/.github/workflows/update-package-lock.yaml +++ b/.github/workflows/update-package-lock.yaml @@ -21,9 +21,6 @@ jobs: runs-on: ubuntu-latest if: github.repository == 'microsoft/TypeScript' - permissions: - contents: write - steps: - uses: actions/checkout@v3 with: @@ -46,7 +43,7 @@ jobs: echo "No change." else npm test - npx hereby lkg + npx hereby LKG git config user.email "typescriptbot@microsoft.com" git config user.name "TypeScript Bot" git add -f package-lock.json