From 80b500b5f22383ff4e062f0f826dcb4264477b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 2 Jan 2025 11:11:31 +0100 Subject: [PATCH 1/9] Build docs as CI artifacts --- .github/workflows/ci.yml | 50 ++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41fe83806..2bcf47a14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ env: node-version: 18.x jobs: - mix_test: + elixir: runs-on: ubuntu-20.04 env: MIX_ENV: test @@ -53,51 +53,45 @@ jobs: - name: Prerelease run: test/prerelease.sh - - name: Generate docs - run: | - mix docs - test -f doc/index.html && echo "doc/index.html exists." - test -f doc/ExDoc.epub && echo "doc/ExDoc.epub exists." - - check_js: - name: Check JS + js: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: node-version: ${{ env.node-version }} + - name: Cache npm dependencies uses: actions/cache@v3 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('asssets/package-lock.json') }} - - run: npm install --prefix assets + + - run: npm ci --prefix assets - run: npm run lint --prefix assets - - run: sudo apt-get install xvfb - - run: | + - name: npm run test --prefix assets + run: | + sudo apt-get install xvfb xvfb-run --auto-servernum npm run test --prefix assets env: CI: true - assets: - needs: [check_js] - runs-on: ubuntu-20.04 - if: github.ref_name == 'main' - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: ${{ env.node-version }} - - name: Cache npm dependencies - uses: actions/cache@v3 - with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('asssets/package-lock.json') }} - - run: npm ci --prefix assets - - run: npm run build --prefix assets - name: Push updated assets + if: github.ref_name == 'main' uses: stefanzweifel/git-auto-commit-action@v4 with: commit_message: Update assets file_pattern: formatters + + - name: Generate docs + run: | + mix build + test -f doc/index.html && echo "doc/index.html exists." + test -f doc/ExDoc.epub && echo "doc/ExDoc.epub exists." + + - name: Upload docs + uses: actions/upload-artifact@v4 + with: + name: docs + path: doc/ From 4f8f9c88e079be24168de3fdf98bdf7932e3475f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 2 Jan 2025 11:23:13 +0100 Subject: [PATCH 2/9] Take 2 --- .github/workflows/ci.yml | 113 ++++++++++++++++++++------------------- 1 file changed, 59 insertions(+), 54 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2bcf47a14..1dbe2b53b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,62 +5,24 @@ on: push: env: - node-version: 18.x + MIX_ENV: test jobs: - elixir: + elixir_js_and_lint: runs-on: ubuntu-20.04 - env: - MIX_ENV: test strategy: - fail-fast: false matrix: include: - - pair: # Test very old Elixir and Erlang - elixir: "1.14" - otp: "25" - - pair: # Test Erlang without -doc attribute support - elixir: "1.16" - otp: "26" - - pair: # Test Erlang with -doc attribute support - elixir: "1.17" - otp: "27" - lint: lint - steps: - - uses: actions/checkout@v3 - - - uses: erlef/setup-beam@v1 - with: - otp-version: ${{matrix.pair.otp}} - elixir-version: ${{matrix.pair.elixir}} - - - name: Install Dependencies - run: mix deps.get - - - run: mix format --check-formatted - if: ${{ matrix.lint }} - - - run: mix deps.unlock --check-unused - if: ${{ matrix.lint }} - - - run: mix deps.compile - - - run: mix compile --warnings-as-errors - if: ${{ matrix.lint }} - - - run: mix test - - - name: Prerelease - run: test/prerelease.sh - - js: - runs-on: ubuntu-20.04 + - elixir: "1.17" + otp: "27" + node: 18.x steps: - uses: actions/checkout@v3 + # Setup Node - uses: actions/setup-node@v3 with: - node-version: ${{ env.node-version }} + node-version: ${{matrix.node}} - name: Cache npm dependencies uses: actions/cache@v3 @@ -69,6 +31,36 @@ jobs: key: ${{ runner.os }}-node-${{ hashFiles('asssets/package-lock.json') }} - run: npm ci --prefix assets + + # Setup Elixir + - uses: erlef/setup-beam@v1 + with: + otp-version: ${{ matrix.otp }} + elixir-version: ${{ matrix.elixir }} + + - run: mix deps.get + + # Generate docs artifact + - name: Generate docs + run: | + mix build + test -f doc/index.html && echo "doc/index.html exists." + test -f doc/ExDoc.epub && echo "doc/ExDoc.epub exists." + + - name: Upload docs + uses: actions/upload-artifact@v4 + with: + name: docs + path: 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 + + # Test JS - run: npm run lint --prefix assets - name: npm run test --prefix assets run: | @@ -77,6 +69,7 @@ jobs: env: CI: true + # Push updated assets if all good - name: Push updated assets if: github.ref_name == 'main' uses: stefanzweifel/git-auto-commit-action@v4 @@ -84,14 +77,26 @@ jobs: commit_message: Update assets file_pattern: formatters - - name: Generate docs - run: | - mix build - test -f doc/index.html && echo "doc/index.html exists." - test -f doc/ExDoc.epub && echo "doc/ExDoc.epub exists." + elixir: + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + include: + # Test very old Elixir and Erlang + - elixir: "1.14" + otp: "25" + # Test Erlang without -doc attribute support + - elixir: "1.16" + otp: "26" + steps: + - uses: actions/checkout@v3 - - name: Upload docs - uses: actions/upload-artifact@v4 + - uses: erlef/setup-beam@v1 with: - name: docs - path: doc/ + otp-version: ${{ matrix.otp }} + elixir-version: ${{ matrix.elixir }} + + - run: mix deps.get + - run: mix test + - run: test/prerelease.sh From 201fa740a13c64fbb808acd0efd4b45d2471d995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 2 Jan 2025 11:36:08 +0100 Subject: [PATCH 3/9] Drop a comment --- .github/workflows/ci.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1dbe2b53b..eed8bb3e4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,9 +49,47 @@ jobs: - name: Upload docs uses: actions/upload-artifact@v4 + id: docs-upload with: name: docs path: doc/ + overwrite: true + + - name: Build update + uses: actions/github-script@v7 + if: github.event_name == 'pull_request' + env: + ARTIFACT_ID: ${{ steps.docs-upload.outputs.artifact-id }} + with: + script: | + const artifactUrl = '$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/artifacts/$ARTIFACT_ID'; + const commentBody = `šŸ“¦ Build artifacts are ready: ${artifactUrl}`; + + const comments = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); + + const botComment = comments.data.find(comment => + comment.body.includes('') + ); + + if (botComment) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: botComment.id, + body: commentBody + }); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: commentBody + }); + } # Test Elixir - run: mix format --check-formatted From 8b911a7c4790a48eb00cec27366f2b1caaaa755d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 2 Jan 2025 11:40:34 +0100 Subject: [PATCH 4/9] Try correct URL --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eed8bb3e4..cc58f115b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: ARTIFACT_ID: ${{ steps.docs-upload.outputs.artifact-id }} with: script: | - const artifactUrl = '$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/artifacts/$ARTIFACT_ID'; + const artifactUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}/artifacts/${process.env.ARTIFACT_ID}`; const commentBody = `šŸ“¦ Build artifacts are ready: ${artifactUrl}`; const comments = await github.rest.issues.listComments({ From 04e8b082ed0b14369ee80b883d6e46b4c5c67ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 2 Jan 2025 11:45:39 +0100 Subject: [PATCH 5/9] Use markdown --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc58f115b..b4ed1b97a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: with: script: | const artifactUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}/artifacts/${process.env.ARTIFACT_ID}`; - const commentBody = `šŸ“¦ Build artifacts are ready: ${artifactUrl}`; + const commentBody = `šŸ“¦ [Build artifacts are ready!](${artifactUrl})`; const comments = await github.rest.issues.listComments({ owner: context.repo.owner, From 4a268150aeec4b26a84896f3f81591bf776ebe75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 2 Jan 2025 11:48:28 +0100 Subject: [PATCH 6/9] Filter by author --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4ed1b97a..66a3648a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,7 +72,8 @@ jobs: }); const botComment = comments.data.find(comment => - comment.body.includes('') + comment.user.login === context.author && + comment.body.includes('') ); if (botComment) { From caa59013ec55e1a10776c1313da868733b246eb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 2 Jan 2025 11:50:11 +0100 Subject: [PATCH 7/9] Newline separator --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 66a3648a3..cbc43a24f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: with: script: | const artifactUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}/artifacts/${process.env.ARTIFACT_ID}`; - const commentBody = `šŸ“¦ [Build artifacts are ready!](${artifactUrl})`; + const commentBody = `\nšŸ“¦ [Docs artifacts are ready!](${artifactUrl})`; const comments = await github.rest.issues.listComments({ owner: context.repo.owner, From ef9dcff3f704d924865c34f61f6dfc6baa6e9b82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 2 Jan 2025 11:53:52 +0100 Subject: [PATCH 8/9] Bot comments only --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cbc43a24f..e3f1b235e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,7 +72,7 @@ jobs: }); const botComment = comments.data.find(comment => - comment.user.login === context.author && + comment.user.type === 'Bot' && comment.body.includes('') ); From 5a02ae2df0e69f32c84b0093f9fed400e447e3c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 2 Jan 2025 11:54:41 +0100 Subject: [PATCH 9/9] Show full URL --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3f1b235e..1b17fd86f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: with: script: | const artifactUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}/artifacts/${process.env.ARTIFACT_ID}`; - const commentBody = `\nšŸ“¦ [Docs artifacts are ready!](${artifactUrl})`; + const commentBody = `\nšŸ“¦ Docs artifacts are ready: ${artifactUrl}`; const comments = await github.rest.issues.listComments({ owner: context.repo.owner,