Skip to content

🖇 Update Integration Test Repositories #129

🖇 Update Integration Test Repositories

🖇 Update Integration Test Repositories #129

name: " 🖇 Update Integration Test Repositories"
on:
workflow_dispatch:
inputs:
ref:
description: Branch or hash
required: false
schedule:
- cron: "0 8 * * 1" # Monday at 8 UTC
permissions:
contents: read
env:
NEW_BRANCH: "update-integration-repositories"
REF_BRANCH_G: main
RUNS_ON: ubuntu-latest
NODE_VERSION: "18.x"
NPM_VERSION: "9"
jobs:
calc-ref:
runs-on: ubuntu-latest
outputs:
ref: ${{ github.event.inputs.ref || env.REF_BRANCH_G }}
steps:
- name: Ref Branch
run: |
echo Ref: "${{ env.REF_BRANCH_G }}"
echo Input: "${{ github.event.inputs.ref }}"
load-integrations:
needs:
- calc-ref
uses: ./.github/workflows/reuseable-load-integrations-repo-list.yml
with:
ref: ${{ needs.calc-ref.outputs.ref }}
dirty: true
build:
needs:
- calc-ref
uses: "./.github/workflows/reuseable-build-dist-cache.yml"
with:
ref: ${{ needs.calc-ref.outputs.ref }}
integrations:
runs-on: ubuntu-latest
needs:
- load-integrations
- build
- calc-ref
env:
REF_BRANCH: ${{ needs.calc-ref.outputs.ref }}
strategy:
# the integration tests are independent, so we want to run them all.
fail-fast: false
matrix:
# List of repositories to check.
# Use `repo-list.sh` in `integration-tests` to generate.
repo: ${{ fromJSON(needs.load-integrations.outputs.repos) }}
# repo:
# # - prettier/prettier
# # - typescript-eslint/typescript-eslint
# - wireapp/wire-webapp
steps:
- name: Build Results
run: |
echo "key: ${{ needs.build.outputs.key }}"
echo "path: ${{ needs.build.outputs.path }}"
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ env.REF_BRANCH }}
- name: Setup pnpm
uses: pnpm/action-setup@v3.0.0
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "pnpm"
- run: pnpm -v
- name: Cache Build
id: step-cache-build
uses: actions/cache@v4
with:
key: ${{ needs.build.outputs.key }}
path: ${{ needs.build.outputs.path }}
- name: Cached Results
run: |
echo Build Cache: ${{ steps.step-cache-build.outputs.cache-hit && 'Hit' || 'Miss' }}
- name: pnpm CI
run: pnpm i
- name: Has pnpm has failed?
if: ${{ failure() }}
run: |
ls -alF /home/runner/.pnpm/_logs/*.log
cat /home/runner/.pnpm/_logs/*.log
- name: Check Build
if: ${{ !steps.step-cache-build.outputs.cache-hit }}
run: exit 1
- name: Run Integration Tests ${{ matrix.repo }}
if: ${{ !steps.step-cache-run.outputs.cache-hit }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >
cd integration-tests
&& pnpm i
&& pnpm run update-repositories -- ${{ matrix.repo }}
- name: Normalize Repo Name
id: step-normalize-repo-name
env:
REPO: ${{ matrix.repo }}
REPLACE: "/"
REPLACE_WITH: "__"
run: |
echo "REPO_NAME=${REPO//${REPLACE}/${REPLACE_WITH}}" >> $GITHUB_OUTPUT
- name: Store Repo Diff
id: step-repo-info
env:
REPO: ${{ steps.step-normalize-repo-name.outputs.REPO_NAME }}
run: |
mkdir temp
echo "${{ matrix.repo }} =>" $REPO
git diff > temp/$REPO.diff
- name: store diff
uses: actions/upload-artifact@v4
with:
name: diffs-repo-${{ steps.step-normalize-repo-name.outputs.REPO_NAME }}
path: temp/*.diff
retention-days: 1
pr-setup:
runs-on: ubuntu-latest
needs:
- integrations
- calc-ref
env:
REF_BRANCH: ${{ needs.calc-ref.outputs.ref }}
outputs:
base: ${{ env.REF_BRANCH }}
body: |
## Update Integration Repositories
commit-message: "ci: Workflow Bot -- Update Integration Snapshots"
branch: ${{ env.NEW_BRANCH }}-${{ env.REF_BRANCH }}
title: "ci: Workflow Bot -- Update Integration Snapshots (${{ env.REF_BRANCH }})"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ env.REF_BRANCH }}
- name: Setup pnpm
uses: pnpm/action-setup@v3.0.0
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "pnpm"
- name: restore repos
uses: actions/download-artifact@v4
with:
pattern: diffs-*
merge-multiple: true
path: temp
- name: show downloaded
run: ls -alF temp
- name: show diff
run: cat temp/*.diff
- name: apply diff
run: git apply --allow-empty temp/*.diff
- name: Update Integrations List
run: |
pnpm run update-integrations-list
- name: Build Patch
run: |
git --no-pager diff > temp/patch.diff
- name: Store Patch
uses: actions/upload-artifact@v4
with:
name: patch
path: temp/patch.diff
retention-days: 1
pr:
uses: ./.github/workflows/reuseable-pr-from-artifact.yml
needs:
- pr-setup
with:
patch_artifact: patch
base: ${{ needs.pr-setup.outputs.base }}
body: ${{ needs.pr-setup.outputs.body }}
commit-message: ${{ needs.pr-setup.outputs.commit-message }}
branch: ${{ needs.pr-setup.outputs.branch }}
title: ${{ needs.pr-setup.outputs.title }}
secrets:
app_id: ${{ secrets.AUTOMATION_APP_ID }}
private_key: ${{ secrets.AUTOMATION_PRIVATE_KEY }}