mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-19 12:23:38 +08:00
ci: move prettier to its own workflow (@miodec) (#6198)
Add pretty fix step if pretty check failed. --------- Co-authored-by: Miodec <13181393+Miodec@users.noreply.github.com>
This commit is contained in:
parent
219b41302e
commit
00e130969a
2 changed files with 72 additions and 54 deletions
.github/workflows
64
.github/workflows/monkey-ci.yml
vendored
64
.github/workflows/monkey-ci.yml
vendored
|
@ -55,11 +55,17 @@ jobs:
|
|||
- 'packages/**/*'
|
||||
anti-cheat:
|
||||
- 'backend/**/anticheat/**'
|
||||
workflows:
|
||||
- '.github/workflows/**/*'
|
||||
|
||||
- name: Check Anti-cheat
|
||||
if: steps.filter.outputs.anti-cheat == 'true'
|
||||
run: exit 1
|
||||
|
||||
- name: Check Workflow Changes
|
||||
if: steps.filter.outputs.workflows == 'true' && !contains(github.event.pull_request.labels.*.name, 'force-ci') && !contains(github.event.pull_request.labels.*.name, 'force-full-ci')
|
||||
run: exit 1
|
||||
|
||||
- name: Export changes
|
||||
id: export-changes
|
||||
run: |
|
||||
|
@ -115,59 +121,9 @@ jobs:
|
|||
name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
check-pretty:
|
||||
name: check-pretty
|
||||
needs: [pre-ci, prime-cache]
|
||||
runs-on: ubuntu-latest
|
||||
if: needs.pre-ci.outputs.should-build-be == 'true' || needs.pre-ci.outputs.should-build-fe == 'true' || needs.pre-ci.outputs.should-build-pkg == 'true' || needs.pre-ci.outputs.assets-json == 'true' || contains(github.event.pull_request.labels.*.name, 'force-full-ci')
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: ${{ env.PNPM_VERSION }}
|
||||
|
||||
- name: Install prettier
|
||||
run: pnpm add -g prettier@2.8.8
|
||||
|
||||
- name: Get changed files
|
||||
if: github.event_name == 'pull_request'
|
||||
id: get-changed-files
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const changedFiles = await github.paginate(
|
||||
github.rest.pulls.listFiles,
|
||||
{
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: context.payload.pull_request.number,
|
||||
}
|
||||
);
|
||||
return changedFiles.filter(file=> file.status !== "removed").map(file => file.filename).join(' ');
|
||||
|
||||
- name: Check pretty (changed files)
|
||||
if: github.event_name == 'pull_request'
|
||||
id: check-pretty
|
||||
run: |
|
||||
CHANGED_FILES=$(echo ${{ steps.get-changed-files.outputs.result }})
|
||||
if [ -n "$CHANGED_FILES" ]; then
|
||||
pnpm prettier --check $CHANGED_FILES
|
||||
fi
|
||||
|
||||
- name: Check pretty (all files)
|
||||
if: github.event_name == 'push'
|
||||
run: pnpm prettier --check .
|
||||
|
||||
ci-be:
|
||||
name: ci-be
|
||||
needs: [pre-ci, prime-cache, check-pretty]
|
||||
needs: [pre-ci, prime-cache]
|
||||
runs-on: ubuntu-latest
|
||||
if: needs.pre-ci.outputs.should-build-be == 'true' || needs.pre-ci.outputs.should-build-pkg == 'true' || contains(github.event.pull_request.labels.*.name, 'force-full-ci')
|
||||
steps:
|
||||
|
@ -215,7 +171,7 @@ jobs:
|
|||
|
||||
ci-fe:
|
||||
name: ci-fe
|
||||
needs: [pre-ci, prime-cache, check-pretty]
|
||||
needs: [pre-ci, prime-cache]
|
||||
runs-on: ubuntu-latest
|
||||
if: needs.pre-ci.outputs.should-build-fe == 'true' || needs.pre-ci.outputs.should-build-pkg == 'true' || contains(github.event.pull_request.labels.*.name, 'force-full-ci')
|
||||
steps:
|
||||
|
@ -268,7 +224,7 @@ jobs:
|
|||
|
||||
ci-assets:
|
||||
name: ci-assets
|
||||
needs: [pre-ci, prime-cache, check-pretty]
|
||||
needs: [pre-ci, prime-cache]
|
||||
runs-on: ubuntu-latest
|
||||
if: needs.pre-ci.outputs.assets-json == 'true' || contains(github.event.pull_request.labels.*.name, 'force-full-ci')
|
||||
steps:
|
||||
|
@ -337,7 +293,7 @@ jobs:
|
|||
|
||||
ci-pkg:
|
||||
name: ci-pkg
|
||||
needs: [pre-ci, prime-cache,check-pretty]
|
||||
needs: [pre-ci, prime-cache]
|
||||
runs-on: ubuntu-latest
|
||||
if: needs.pre-ci.outputs.should-build-pkg == 'true' || contains(github.event.pull_request.labels.*.name, 'force-full-ci')
|
||||
steps:
|
||||
|
|
62
.github/workflows/pretty-check.yml
vendored
Normal file
62
.github/workflows/pretty-check.yml
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
name: Prettier Check
|
||||
|
||||
env:
|
||||
PNPM_VERSION: "9.6.0"
|
||||
NODE_VERSION: "20.16.0"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [master]
|
||||
types: [opened, reopened, synchronize, ready_for_review]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: group-pretty-check-${{ github.ref }}-${{ github.workflow }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
check:
|
||||
if: github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'force-ci') || contains(github.event.pull_request.labels.*.name, 'force-full-ci')
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Full checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: ${{ env.PNPM_VERSION }}
|
||||
|
||||
- name: Install prettier
|
||||
run: pnpm add -g prettier@2.8.8
|
||||
|
||||
- name: Get changed files
|
||||
id: get-changed-files
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const changedFiles = await github.paginate(
|
||||
github.rest.pulls.listFiles,
|
||||
{
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: context.payload.pull_request.number,
|
||||
}
|
||||
);
|
||||
return changedFiles.filter(file=> file.status !== "removed").map(file => file.filename).join(' ');
|
||||
|
||||
- name: Check pretty (changed files)
|
||||
run: |
|
||||
CHANGED_FILES=$(echo ${{ steps.get-changed-files.outputs.result }})
|
||||
if [ -n "$CHANGED_FILES" ]; then
|
||||
pnpm prettier --check $CHANGED_FILES
|
||||
fi
|
||||
|
Loading…
Reference in a new issue