From eebebbca64ff8e547263a5735dd718b33a395f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 3 Jan 2025 12:42:36 +0100 Subject: [PATCH 1/7] Updates --- .github/workflows/artifacts.yml | 16 +++++++++++-- .github/workflows/ci.yml | 40 +++++++++++++++++++++------------ test/prerelease.sh | 8 +++++-- 3 files changed, 46 insertions(+), 18 deletions(-) diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml index 221bdad86..198e6ba41 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/artifacts.yml @@ -28,8 +28,20 @@ jobs: throw new Error('Expected one artifact') } - const pullNumber = context.payload.workflow_run.pull_requests[0].number; - const artifactUrl = artifacts.data.artifacts[0].archive_download_url; + const artifact = artifacts.data.artifacts[0]; + const download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: artifact.id, + archive_format: 'zip' + }); + + const zlib = require('zlib'); + const zip = zlib.unzipSync(Buffer.from(download.data)); + const ghInfo = JSON.parse(zip.toString()); + const pullNumber = ghInfo.number; + + const artifactUrl = artifact.archive_download_url; const commentBody = `\n📦 Docs artifacts are ready: ${artifactUrl}`; const comments = await github.rest.issues.listComments({ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5f915454a..e776a35fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ env: MIX_ENV: test jobs: - elixir_js_and_lint: + assets: runs-on: ubuntu-20.04 strategy: matrix: @@ -29,6 +29,7 @@ jobs: key: ${{ runner.os }}-node-${{ hashFiles('asssets/package-lock.json') }} - run: npm ci --prefix assets + - run: npm run build --prefix assets # Setup Elixir - uses: erlef/setup-beam@v1 @@ -36,28 +37,26 @@ jobs: otp-version: ${{ matrix.otp }} elixir-version: ${{ matrix.elixir }} - - run: mix deps.get - # Generate and upload artifacts - name: Generate docs + run: test/prerelease.sh + + - name: Docs metadata run: | - mix build - test -f doc/index.html && echo "doc/index.html exists." - test -f doc/ExDoc.epub && echo "doc/ExDoc.epub exists." + echo "{\"pr_number\":${{ github.event.number }},\"artifact_id\":${{ steps.docs-upload.outputs.artifact-id }}}" > test/tmp/contents/doc/gh.json - name: Upload docs uses: actions/upload-artifact@v4 id: docs-upload with: name: docs - path: doc/ + path: test/tmp/contents/doc/ - # Test Elixir - - run: mix format --check-formatted - - run: mix deps.unlock --check-unused - - run: mix compile --force --warnings-as-errors - - run: mix test - - run: test/prerelease.sh + - name: Dispatch docs + uses: actions/github-script@v7 + if: github.event_name == 'pull_request' + env: + ARTIFACT_ID: ${{ steps.docs-upload.outputs.artifact-id }} # Test JS - run: npm run lint --prefix assets @@ -88,6 +87,10 @@ jobs: # Test Erlang without -doc attribute support - elixir: "1.16" otp: "26" + # Test Erlang with -doc attribute support + - elixir: "1.17" + otp: "27" + lint: true steps: - uses: actions/checkout@v3 @@ -97,5 +100,14 @@ jobs: elixir-version: ${{ matrix.elixir }} - run: mix deps.get + + - run: mix compile --warnings-as-errors + if: ${{ matrix.lint }} + - run: mix test - - run: test/prerelease.sh + + - run: mix deps.unlock --check-unused + if: ${{ matrix.lint }} + + - run: mix format --check-formatted + if: ${{ matrix.lint }} diff --git a/test/prerelease.sh b/test/prerelease.sh index f1e95ba1e..bb3999bbb 100755 --- a/test/prerelease.sh +++ b/test/prerelease.sh @@ -1,5 +1,5 @@ #!/bin/bash -PKG=test/tmp/package +PKG=test/tmp # build package mix hex.build @@ -10,4 +10,8 @@ TAR=$(ls ex_doc-*.tar | head -n 1) rm -rf $PKG && mkdir -p $PKG/contents && tar xf $TAR -C $PKG && tar xzf $PKG/contents.tar.gz -C $PKG/contents # compile and build docs -cd $PKG/contents && MIX_ENV=prod mix do deps.get --only prod, compile, docs +cd $PKG/contents && MIX_ENV=prod mix deps.get --only prod + compile + docs + +# run assertions +test -f doc/index.html && echo "doc/index.html exists" +test -f doc/ExDoc.epub && echo "doc/ExDoc.epub exists" \ No newline at end of file From 033a505a07a5f3995960c7155185dfe78b654fdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 3 Jan 2025 12:44:22 +0100 Subject: [PATCH 2/7] Update --- .github/workflows/ci.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e776a35fd..5dd0acd15 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,12 +52,6 @@ jobs: name: docs path: test/tmp/contents/doc/ - - name: Dispatch docs - uses: actions/github-script@v7 - if: github.event_name == 'pull_request' - env: - ARTIFACT_ID: ${{ steps.docs-upload.outputs.artifact-id }} - # Test JS - run: npm run lint --prefix assets - name: npm run test --prefix assets From bb4c8ff41108c2fb3db37a681954653e5f0a682c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 3 Jan 2025 12:46:38 +0100 Subject: [PATCH 3/7] Fixes --- test/prerelease.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/prerelease.sh b/test/prerelease.sh index bb3999bbb..85930f4cc 100755 --- a/test/prerelease.sh +++ b/test/prerelease.sh @@ -10,8 +10,8 @@ TAR=$(ls ex_doc-*.tar | head -n 1) rm -rf $PKG && mkdir -p $PKG/contents && tar xf $TAR -C $PKG && tar xzf $PKG/contents.tar.gz -C $PKG/contents # compile and build docs -cd $PKG/contents && MIX_ENV=prod mix deps.get --only prod + compile + docs +cd $PKG/contents && MIX_ENV=prod mix do deps.get --only prod + compile + docs # run assertions -test -f doc/index.html && echo "doc/index.html exists" -test -f doc/ExDoc.epub && echo "doc/ExDoc.epub exists" \ No newline at end of file +test -f doc/index.html || echo "doc/index.html missing" +test -f doc/ExDoc.epub || echo "doc/ExDoc.epub missing" \ No newline at end of file From 3e5752c780eae196d17a48ad242b17d369fdb5f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 3 Jan 2025 12:50:34 +0100 Subject: [PATCH 4/7] Simplify --- .github/workflows/artifacts.yml | 21 ++------------------- .github/workflows/ci.yml | 4 ---- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml index 198e6ba41..8d9f53b89 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/artifacts.yml @@ -23,38 +23,21 @@ jobs: repo: context.repo.repo, run_id: context.payload.workflow_run.id }); - if (artifacts.data.total_count !== 1) { throw new Error('Expected one artifact') } - - const artifact = artifacts.data.artifacts[0]; - const download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: artifact.id, - archive_format: 'zip' - }); - - const zlib = require('zlib'); - const zip = zlib.unzipSync(Buffer.from(download.data)); - const ghInfo = JSON.parse(zip.toString()); - const pullNumber = ghInfo.number; - - const artifactUrl = artifact.archive_download_url; + const pullNumber = context.payload.workflow_run.pull_requests[0].number; + const artifactUrl = artifacts.data.artifacts[0].archive_download_url; const commentBody = `\n📦 Docs artifacts are ready: ${artifactUrl}`; - const comments = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, issue_number: pullNumber }); - const botComment = comments.data.find(comment => comment.user.type === 'Bot' && comment.body.includes('') ); - if (botComment) { await github.rest.issues.updateComment({ owner: context.repo.owner, diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5dd0acd15..d3be1216f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,10 +41,6 @@ jobs: - name: Generate docs run: test/prerelease.sh - - name: Docs metadata - run: | - echo "{\"pr_number\":${{ github.event.number }},\"artifact_id\":${{ steps.docs-upload.outputs.artifact-id }}}" > test/tmp/contents/doc/gh.json - - name: Upload docs uses: actions/upload-artifact@v4 id: docs-upload From aee692539e98e30696de546b869d8419117e9e39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 3 Jan 2025 12:51:46 +0100 Subject: [PATCH 5/7] Fixes --- .github/workflows/artifacts.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml index 8d9f53b89..8d8796ed3 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/artifacts.yml @@ -23,21 +23,27 @@ jobs: repo: context.repo.repo, run_id: context.payload.workflow_run.id }); + if (artifacts.data.total_count !== 1) { throw new Error('Expected one artifact') } + const pullNumber = context.payload.workflow_run.pull_requests[0].number; const artifactUrl = artifacts.data.artifacts[0].archive_download_url; + const commentBody = `\n📦 Docs artifacts are ready: ${artifactUrl}`; + const comments = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, issue_number: pullNumber }); + const botComment = comments.data.find(comment => comment.user.type === 'Bot' && comment.body.includes('') ); + if (botComment) { await github.rest.issues.updateComment({ owner: context.repo.owner, From cb6fe9d4f54ca50aef475c7aa6a52548ac59bfab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 3 Jan 2025 12:52:26 +0100 Subject: [PATCH 6/7] Done --- .github/workflows/artifacts.yml | 1 - test/prerelease.sh | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml index 8d8796ed3..221bdad86 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/artifacts.yml @@ -30,7 +30,6 @@ jobs: const pullNumber = context.payload.workflow_run.pull_requests[0].number; const artifactUrl = artifacts.data.artifacts[0].archive_download_url; - const commentBody = `\n📦 Docs artifacts are ready: ${artifactUrl}`; const comments = await github.rest.issues.listComments({ diff --git a/test/prerelease.sh b/test/prerelease.sh index 85930f4cc..ac0113fc6 100755 --- a/test/prerelease.sh +++ b/test/prerelease.sh @@ -14,4 +14,4 @@ cd $PKG/contents && MIX_ENV=prod mix do deps.get --only prod + compile + docs # run assertions test -f doc/index.html || echo "doc/index.html missing" -test -f doc/ExDoc.epub || echo "doc/ExDoc.epub missing" \ No newline at end of file +test -f doc/ExDoc.epub || echo "doc/ExDoc.epub missing" From de461a7356647b49ce50843d8a1ef2145f257835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 3 Jan 2025 12:56:04 +0100 Subject: [PATCH 7/7] Finally --- .github/workflows/artifacts.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml index 221bdad86..d7555ea73 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/artifacts.yml @@ -29,7 +29,8 @@ jobs: } const pullNumber = context.payload.workflow_run.pull_requests[0].number; - const artifactUrl = artifacts.data.artifacts[0].archive_download_url; + const artifactId = artifacts.data.artifacts[0].id; + const artifactUrl = `${context.payload.workflow_run.artifacts_url}/${artifactId}`; const commentBody = `\n📦 Docs artifacts are ready: ${artifactUrl}`; const comments = await github.rest.issues.listComments({