Skip to content

Commit

Permalink
add a "cleanup-checks" trigger action (#11354)
Browse files Browse the repository at this point in the history
Co-authored-by: phryneas <[email protected]>
  • Loading branch information
phryneas and phryneas authored Nov 17, 2023
1 parent ae5091a commit 60b7e56
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 6 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/cleanup-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Clean up Prettier, Size-limit, and Api-Extractor

on:
pull_request:
pull_request_review:
types: [submitted, edited]

jobs:
add_cleanup_label:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-when-a-pull-request-is-approved
if: |
github.repository == 'apollographql/apollo-client' &&
github.event.review.state == 'APPROVED' &&
contains(github.event.pull_request.labels.*.name, 'auto-cleanup') == false
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: add label
uses: actions-ecosystem/action-add-labels@v1
with:
labels: auto-cleanup

cleanup:
if: |
github.repository == 'apollographql/apollo-client' &&
contains(github.event.pull_request.labels.*.name, 'auto-cleanup')
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x

- name: Install dependencies (with cache)
uses: bahmutov/npm-install@v1

- name: Run build
run: npm run build

- name: Run Api-Extractor
run: npm run extract-api
env:
CI: "false"

- name: Run prettier
run: npm run format

- name: Update size-limit
run: npm run update-size-limits

- name: Commit changes back
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Clean up Prettier, Size-limit, and Api-Extractor"
push_options: ""
skip_dirty_check: false
12 changes: 8 additions & 4 deletions .size-limit.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const limits = require("./.size-limits.json");

const checks = [
{
path: "dist/apollo-client.min.cjs",
limit: "37975",
},
{
path: "dist/main.cjs",
Expand All @@ -10,7 +11,6 @@ const checks = [
{
path: "dist/index.js",
import: "{ ApolloClient, InMemoryCache, HttpLink }",
limit: "32019",
},
...[
"ApolloProvider",
Expand Down Expand Up @@ -53,7 +53,7 @@ const checks = [
value.path == "dist/apollo-client.min.cjs"
? value
: [
{ ...value, limit: undefined },
value,
{
...value,
name: `${value.name} (production)`,
Expand All @@ -65,6 +65,10 @@ const checks = [
},
},
]
);
)
.map((value) => {
value.limit = limits[value.name];
return value;
});

module.exports = checks;
4 changes: 4 additions & 0 deletions .size-limits.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"dist/apollo-client.min.cjs": 37975,
"import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 32019
}
2 changes: 1 addition & 1 deletion config/apiExtractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ map((entryPoint: { dirs: string[] }) => {
});

const extractorResult: ExtractorResult = Extractor.invoke(extractorConfig, {
localBuild: process.env.CI === undefined,
localBuild: process.env.CI === undefined || process.env.CI === "false",
showVerboseMessages: true,
});

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
"typedoc": "typedoc src/index.ts --json docs/public/docs.json",
"changeset-publish": "npm run build && npm run prepdist:changesets && cd dist && changeset publish",
"changeset-check": "changeset status --verbose --since=origin/main",
"changeset-version": "changeset version && npm i"
"changeset-version": "changeset version && npm i",
"update-size-limits": "size-limit --json | jq '. | map(select(.sizeLimit) | { key: .name, value: .size}) | from_entries' | tee .new-size-limits.json; mv .new-size-limits.json .size-limits.json"
},
"engines": {
"npm": "^7.20.3 || ^8.0.0 || ^9.0.0 || ^10.0.0"
Expand Down

0 comments on commit 60b7e56

Please sign in to comment.