From 06bd2689c6ce2df6b2ff5c6710ff568b1ea5389f Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 2 Aug 2024 16:12:29 +0200 Subject: [PATCH 1/7] Change build command to custom shell script --- netlify.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netlify.toml b/netlify.toml index 7b5d7e71f..514d93a72 100644 --- a/netlify.toml +++ b/netlify.toml @@ -2,7 +2,7 @@ # Basic configuration for a Netlify deployment [build] publish = "" # Directory to publish - command = "npx respec -s index.html -o index.html --localhost; npx respec -s accname/index.html -o accname/index.html --localhost; npx respec -s core-aam/index.html -o core-aam/index.html --localhost; npx respec -s dpub-aam/index.html -o dpub-aam/index.html --localhost; npx respec -s dpub-aria/index.html -o dpub-aria/index.html --localhost; npx respec -s graphics-aam/index.html -o graphics-aam/index.html --localhost; npx respec -s graphics-aria/index.html -o graphics-aria/index.html --localhost; npx respec -s svg-aam/index.html -o svg-aam/index.html --localhost; npx respec -s mathml-aam/index.html -o mathml-aam/index.html --localhost" + command = "./pr-preview.sh" [[redirects]] from = "/*" From edd2799b69e8e007f84a483d6207866489ff70d7 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 2 Aug 2024 16:12:53 +0200 Subject: [PATCH 2/7] Add shell script --- pr-preview.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 pr-preview.sh diff --git a/pr-preview.sh b/pr-preview.sh new file mode 100755 index 000000000..5d7b61278 --- /dev/null +++ b/pr-preview.sh @@ -0,0 +1,46 @@ +# change specStatus value to include relative paths +echo "Updating specStatus to unofficial" +find . -name "index.html" -exec sed -i 's/specStatus:[[:space:]]*"ED"/specStatus: "unofficial"/g' {} + + +# update spec URLs mappings for ARIA +echo "updating ARIA mappings" +find . -wholename "./index.html" -exec sed -i 's/ariaSpecURLs: {/ariaSpecURLs: {\n "unofficial": "\/",/g' {} + +find . -wholename "./index.html" -exec sed -i 's/accNameURLs: {/accNameURLs: {\n "unofficial": ".\/accname\/",/g' {} + +find . -wholename "./index.html" -exec sed -i 's/coreMappingURLs: {/coreMappingURLs: {\n "unofficial": ".\/core-aam\/",/g' {} + + +# update specURLs mapping for child specs +echo "updating child spec mappings" +# aria +find . -mindepth 1 -name "index.html" -exec sed -i 's/ariaSpecURLs: {/ariaSpecURLs: {\n "unofficial": "..\/",/g' {} + +# accname +find . -mindepth 1 -name "index.html" -exec sed -i 's/accNameURLs: {/accNameURLs: {\n "unofficial": "..\/accname\/",/g' {} + +# core-aam +find . -mindepth 1 -name "index.html" -exec sed -i 's/coreMappingURLs: {/coreMappingURLs: {\n "unofficial": "..\/core-aam\/",/g' {} + +# dpub +find . -mindepth 1 -name "index.html" -exec sed -i 's/dpubModURLs: {/dpubModURLs: {\n "unofficial": "..\/dpub-aria\/",/g' {} + +# graphicsMappingModURLs +find . -mindepth 1 -name "index.html" -exec sed -i 's/graphicsMappingModURLs: {/graphicsMappingModURLs: {\n "unofficial": "..\/graphics-aam\/",/g' {} + +# graphicsModURLs +find . -mindepth 1 -name "index.html" -exec sed -i 's/graphicsModURLs: {/graphicsModURLs: {\n "unofficial": "..\/graphics-aria\/",/g' {} + +# htmlMappingURLs +find . -mindepth 1 -name "index.html" -exec sed -i 's/htmlMappingURLs: {/htmlMappingURLs: {\n "unofficial": "..\/html-aam\/",/g' {} + +# build all specs +echo "building specs" + +commands=( + "npx respec -s index.html -o index.html --localhost" + "npx respec -s accname/index.html -o accname/index.html --localhost" + "npx respec -s core-aam/index.html -o core-aam/index.html --localhost" + "npx respec -s dpub-aam/index.html -o dpub-aam/index.html --localhost" + "npx respec -s dpub-aria/index.html -o dpub-aria/index.html --localhost" + "npx respec -s graphics-aam/index.html -o graphics-aam/index.html --localhost" + "npx respec -s graphics-aria/index.html -o graphics-aria/index.html --localhost" + "npx respec -s svg-aam/index.html -o svg-aam/index.html --localhost" + "npx respec -s mathml-aam/index.html -o mathml-aam/index.html --localhost" +) +for cmd in "${commands[@]}"; do + echo "Executing: $cmd" + if ! $cmd; then + echo "Error: Command failed - $cmd" + fi +done From 2408f339aa4de84d68a547940d7cb1eacd948c38 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 8 Aug 2024 17:23:44 +0200 Subject: [PATCH 3/7] Relates to #2294 Update prettier to deal with PRs from forks --- .github/workflows/prettier.yaml | 102 ++++++++++++++++++++++++++++++-- 1 file changed, 98 insertions(+), 4 deletions(-) diff --git a/.github/workflows/prettier.yaml b/.github/workflows/prettier.yaml index 284800354..2f0c5d6a0 100644 --- a/.github/workflows/prettier.yaml +++ b/.github/workflows/prettier.yaml @@ -1,4 +1,58 @@ -name: Prettier +{ + "action": "opened", + "number": 42, + "pull_request": { + "url": "https://api.github.com/repos/octocat/Hello-World/pulls/42", + "id": 279147437, + "head": { + "repo": { + "fork": true, + "url": "https://api.github.com/repos/octocat/Hello-World" + } + }, + "base": { + "repo": { + "url": "https://api.github.com/repos/octocat/Hello-World" + } + } + }, + "repository": { + "id": 1296269, + "name": "Hello-World", + "full_name": "octocat/Hello-World" + }, + "sender": { + "login": "octocat", + "id": 1 + } +}{ + "action": "opened", + "number": 42, + "pull_request": { + "url": "https://api.github.com/repos/octocat/Hello-World/pulls/42", + "id": 279147437, + "head": { + "repo": { + "fork": true, + "url": "https://api.github.com/repos/octocat/Hello-World" + } + }, + "base": { + "repo": { + "url": "https://api.github.com/repos/octocat/Hello-World" + } + } + }, + "repository": { + "id": 1296269, + "name": "Hello-World", + "full_name": "octocat/Hello-World" + }, + "sender": { + "login": "octocat", + "id": 1 + } +}name: Prettier # minimally modified from https://github.com/creyD/prettier_action#example-2-using-the-only_changed-or-same_commit-option-on-pr on: @@ -13,15 +67,55 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - # Make sure the actual branch is checked out when running on pull requests - ref: ${{ github.head_ref }} + # Make sure the actual branch is checked out when running on pull requests even from forks + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} # This is important to fetch the changes to the previous commit fetch-depth: 0 + - name: Check if PR is from a fork + id: check_fork + run: echo "::set-output name=is_fork::${{ github.event.pull_request.head.repo.fork }}" + - name: Prettify code + id: prettify uses: creyD/prettier_action@v4.3 with: prettier_options: --write **/index.html --print-width 200 commit_message: "chore: prettier" + continue-on-error: true +{ + "action": "opened", + "number": 42, + "pull_request": { + "url": "https://api.github.com/repos/octocat/Hello-World/pulls/42", + "id": 279147437, + "head": { + "repo": { + "fork": true, + "url": "https://api.github.com/repos/octocat/Hello-World" + } + }, + "base": { + "repo": { + "url": "https://api.github.com/repos/octocat/Hello-World" + } + } + }, + "repository": { + "id": 1296269, + "name": "Hello-World", + "full_name": "octocat/Hello-World" + }, + "sender": { + "login": "octocat", + "id": 1 + } +} + - name: Handle commit failure + if: ${{ steps.prettify.outcome == 'failure' && steps.check_fork.outputs.is_fork == 'true' }} + run: echo > + please [allow maintainers to edit your PR](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) + From d53b6a0058e5ea9da2821ce7d44ee1c9cee36ee6 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 8 Aug 2024 17:34:46 +0200 Subject: [PATCH 4/7] Handle forks --- .github/workflows/prettier.yaml | 93 ++------------------------------- 1 file changed, 4 insertions(+), 89 deletions(-) diff --git a/.github/workflows/prettier.yaml b/.github/workflows/prettier.yaml index 2f0c5d6a0..e8d0f90df 100644 --- a/.github/workflows/prettier.yaml +++ b/.github/workflows/prettier.yaml @@ -1,58 +1,4 @@ -{ - "action": "opened", - "number": 42, - "pull_request": { - "url": "https://api.github.com/repos/octocat/Hello-World/pulls/42", - "id": 279147437, - "head": { - "repo": { - "fork": true, - "url": "https://api.github.com/repos/octocat/Hello-World" - } - }, - "base": { - "repo": { - "url": "https://api.github.com/repos/octocat/Hello-World" - } - } - }, - "repository": { - "id": 1296269, - "name": "Hello-World", - "full_name": "octocat/Hello-World" - }, - "sender": { - "login": "octocat", - "id": 1 - } -}{ - "action": "opened", - "number": 42, - "pull_request": { - "url": "https://api.github.com/repos/octocat/Hello-World/pulls/42", - "id": 279147437, - "head": { - "repo": { - "fork": true, - "url": "https://api.github.com/repos/octocat/Hello-World" - } - }, - "base": { - "repo": { - "url": "https://api.github.com/repos/octocat/Hello-World" - } - } - }, - "repository": { - "id": 1296269, - "name": "Hello-World", - "full_name": "octocat/Hello-World" - }, - "sender": { - "login": "octocat", - "id": 1 - } -}name: Prettier +name: Prettier # minimally modified from https://github.com/creyD/prettier_action#example-2-using-the-only_changed-or-same_commit-option-on-pr on: @@ -67,12 +13,10 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v3 with: - # Make sure the actual branch is checked out when running on pull requests even from forks ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} - # This is important to fetch the changes to the previous commit fetch-depth: 0 - name: Check if PR is from a fork @@ -86,36 +30,7 @@ jobs: prettier_options: --write **/index.html --print-width 200 commit_message: "chore: prettier" continue-on-error: true -{ - "action": "opened", - "number": 42, - "pull_request": { - "url": "https://api.github.com/repos/octocat/Hello-World/pulls/42", - "id": 279147437, - "head": { - "repo": { - "fork": true, - "url": "https://api.github.com/repos/octocat/Hello-World" - } - }, - "base": { - "repo": { - "url": "https://api.github.com/repos/octocat/Hello-World" - } - } - }, - "repository": { - "id": 1296269, - "name": "Hello-World", - "full_name": "octocat/Hello-World" - }, - "sender": { - "login": "octocat", - "id": 1 - } -} + - name: Handle commit failure if: ${{ steps.prettify.outcome == 'failure' && steps.check_fork.outputs.is_fork == 'true' }} - run: echo > - please [allow maintainers to edit your PR](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) - + run: echo "Commit failed due to lack of permissions. Please update permissions." From f2a3635fa8172d2d07a8aebc7c01396130eed913 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 8 Aug 2024 17:36:54 +0200 Subject: [PATCH 5/7] Workflow_dispatch --- .github/workflows/prettier.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/prettier.yaml b/.github/workflows/prettier.yaml index e8d0f90df..f24906185 100644 --- a/.github/workflows/prettier.yaml +++ b/.github/workflows/prettier.yaml @@ -2,6 +2,7 @@ name: Prettier # minimally modified from https://github.com/creyD/prettier_action#example-2-using-the-only_changed-or-same_commit-option-on-pr on: + workflow_dispatch: pull_request: branches: - main From 78d7ddc4b89bc2945ce5898785758a682191c5b3 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 28 Aug 2024 11:44:01 +0200 Subject: [PATCH 6/7] Restore prettier --- .github/workflows/prettier.yaml | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/workflows/prettier.yaml b/.github/workflows/prettier.yaml index f24906185..284800354 100644 --- a/.github/workflows/prettier.yaml +++ b/.github/workflows/prettier.yaml @@ -2,7 +2,6 @@ name: Prettier # minimally modified from https://github.com/creyD/prettier_action#example-2-using-the-only_changed-or-same_commit-option-on-pr on: - workflow_dispatch: pull_request: branches: - main @@ -16,22 +15,13 @@ jobs: - name: Checkout uses: actions/checkout@v3 with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} + # Make sure the actual branch is checked out when running on pull requests + ref: ${{ github.head_ref }} + # This is important to fetch the changes to the previous commit fetch-depth: 0 - - name: Check if PR is from a fork - id: check_fork - run: echo "::set-output name=is_fork::${{ github.event.pull_request.head.repo.fork }}" - - name: Prettify code - id: prettify uses: creyD/prettier_action@v4.3 with: prettier_options: --write **/index.html --print-width 200 commit_message: "chore: prettier" - continue-on-error: true - - - name: Handle commit failure - if: ${{ steps.prettify.outcome == 'failure' && steps.check_fork.outputs.is_fork == 'true' }} - run: echo "Commit failed due to lack of permissions. Please update permissions." From 74efea99fa3419bc30fa2a9a59e7506101b4acb5 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 28 Aug 2024 12:10:54 +0200 Subject: [PATCH 7/7] Update netlify.toml and build script --- netlify.toml | 6 ++++-- pr-preview.sh | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/netlify.toml b/netlify.toml index 514d93a72..e322518ab 100644 --- a/netlify.toml +++ b/netlify.toml @@ -2,7 +2,7 @@ # Basic configuration for a Netlify deployment [build] publish = "" # Directory to publish - command = "./pr-preview.sh" + command = "npx respec -s index.html -o index.html --localhost; npx respec -s accname/index.html -o accname/index.html --localhost; npx respec -s core-aam/index.html -o core-aam/index.html --localhost; npx respec -s dpub-aam/index.html -o dpub-aam/index.html --localhost; npx respec -s dpub-aria/index.html -o dpub-aria/index.html --localhost; npx respec -s graphics-aam/index.html -o graphics-aam/index.html --localhost; npx respec -s graphics-aria/index.html -o graphics-aria/index.html --localhost; npx respec -s svg-aam/index.html -o svg-aam/index.html --localhost; npx respec -s mathml-aam/index.html -o mathml-aam/index.html --localhost" [[redirects]] from = "/*" @@ -14,6 +14,8 @@ [context.deploy-preview] NODE_ENV = "Deploy" + command = "./pr-preview.sh" [context.branch-deploy.environment] - NODE_ENV = "development" \ No newline at end of file + NODE_ENV = "development" + command = "./pr-preview.sh" \ No newline at end of file diff --git a/pr-preview.sh b/pr-preview.sh index 5d7b61278..6dffe44ab 100755 --- a/pr-preview.sh +++ b/pr-preview.sh @@ -8,8 +8,8 @@ find . -wholename "./index.html" -exec sed -i 's/ariaSpecURLs: {/ariaSpecURLs: { find . -wholename "./index.html" -exec sed -i 's/accNameURLs: {/accNameURLs: {\n "unofficial": ".\/accname\/",/g' {} + find . -wholename "./index.html" -exec sed -i 's/coreMappingURLs: {/coreMappingURLs: {\n "unofficial": ".\/core-aam\/",/g' {} + -# update specURLs mapping for child specs -echo "updating child spec mappings" +# update child specs URLs mapping +echo "updating child spec URL mappings" # aria find . -mindepth 1 -name "index.html" -exec sed -i 's/ariaSpecURLs: {/ariaSpecURLs: {\n "unofficial": "..\/",/g' {} + # accname