|
5 | 5 | push: |
6 | 6 |
|
7 | 7 | env: |
8 | | - node-version: 18.x |
| 8 | + MIX_ENV: test |
9 | 9 |
|
10 | 10 | jobs: |
11 | | - mix_test: |
| 11 | + elixir_js_and_lint: |
12 | 12 | runs-on: ubuntu-20.04 |
13 | | - env: |
14 | | - MIX_ENV: test |
15 | 13 | strategy: |
16 | | - fail-fast: false |
17 | 14 | matrix: |
18 | 15 | include: |
19 | | - - pair: # Test very old Elixir and Erlang |
20 | | - elixir: "1.14" |
21 | | - otp: "25" |
22 | | - - pair: # Test Erlang without -doc attribute support |
23 | | - elixir: "1.16" |
24 | | - otp: "26" |
25 | | - - pair: # Test Erlang with -doc attribute support |
26 | | - elixir: "1.17" |
27 | | - otp: "27" |
28 | | - lint: lint |
| 16 | + - elixir: "1.17" |
| 17 | + otp: "27" |
| 18 | + node: 18.x |
29 | 19 | steps: |
30 | 20 | - uses: actions/checkout@v3 |
31 | 21 |
|
32 | | - - uses: erlef/setup-beam@v1 |
| 22 | + # Setup Node |
| 23 | + - uses: actions/setup-node@v3 |
33 | 24 | with: |
34 | | - otp-version: ${{matrix.pair.otp}} |
35 | | - elixir-version: ${{matrix.pair.elixir}} |
36 | | - |
37 | | - - name: Install Dependencies |
38 | | - run: mix deps.get |
39 | | - |
40 | | - - run: mix format --check-formatted |
41 | | - if: ${{ matrix.lint }} |
42 | | - |
43 | | - - run: mix deps.unlock --check-unused |
44 | | - if: ${{ matrix.lint }} |
| 25 | + node-version: ${{matrix.node}} |
45 | 26 |
|
46 | | - - run: mix deps.compile |
| 27 | + - name: Cache npm dependencies |
| 28 | + uses: actions/cache@v3 |
| 29 | + with: |
| 30 | + path: ~/.npm |
| 31 | + key: ${{ runner.os }}-node-${{ hashFiles('asssets/package-lock.json') }} |
47 | 32 |
|
48 | | - - run: mix compile --warnings-as-errors |
49 | | - if: ${{ matrix.lint }} |
| 33 | + - run: npm ci --prefix assets |
50 | 34 |
|
51 | | - - run: mix test |
| 35 | + # Setup Elixir |
| 36 | + - uses: erlef/setup-beam@v1 |
| 37 | + with: |
| 38 | + otp-version: ${{ matrix.otp }} |
| 39 | + elixir-version: ${{ matrix.elixir }} |
52 | 40 |
|
53 | | - - name: Prerelease |
54 | | - run: test/prerelease.sh |
| 41 | + - run: mix deps.get |
55 | 42 |
|
| 43 | + # Generate docs artifact |
56 | 44 | - name: Generate docs |
57 | 45 | run: | |
58 | | - mix docs |
| 46 | + mix build |
59 | 47 | test -f doc/index.html && echo "doc/index.html exists." |
60 | 48 | test -f doc/ExDoc.epub && echo "doc/ExDoc.epub exists." |
61 | 49 |
|
62 | | - check_js: |
63 | | - name: Check JS |
64 | | - runs-on: ubuntu-20.04 |
65 | | - steps: |
66 | | - - uses: actions/checkout@v3 |
67 | | - - uses: actions/setup-node@v3 |
| 50 | + - name: Upload docs |
| 51 | + uses: actions/upload-artifact@v4 |
| 52 | + id: docs-upload |
68 | 53 | with: |
69 | | - node-version: ${{ env.node-version }} |
70 | | - - name: Cache npm dependencies |
71 | | - uses: actions/cache@v3 |
| 54 | + name: docs |
| 55 | + path: doc/ |
| 56 | + overwrite: true |
| 57 | + |
| 58 | + - name: Build update |
| 59 | + uses: actions/github-script@v7 |
| 60 | + if: github.event_name == 'pull_request' |
| 61 | + env: |
| 62 | + ARTIFACT_ID: ${{ steps.docs-upload.outputs.artifact-id }} |
72 | 63 | with: |
73 | | - path: ~/.npm |
74 | | - key: ${{ runner.os }}-node-${{ hashFiles('asssets/package-lock.json') }} |
75 | | - - run: npm install --prefix assets |
| 64 | + script: | |
| 65 | + const artifactUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}/artifacts/${process.env.ARTIFACT_ID}`; |
| 66 | + const commentBody = `<!-- build-artifact-comment -->\n📦 Docs artifacts are ready: ${artifactUrl}`; |
| 67 | +
|
| 68 | + const comments = await github.rest.issues.listComments({ |
| 69 | + owner: context.repo.owner, |
| 70 | + repo: context.repo.repo, |
| 71 | + issue_number: context.issue.number, |
| 72 | + }); |
| 73 | +
|
| 74 | + const botComment = comments.data.find(comment => |
| 75 | + comment.user.type === 'Bot' && |
| 76 | + comment.body.includes('<!-- build-artifact-comment -->') |
| 77 | + ); |
| 78 | +
|
| 79 | + if (botComment) { |
| 80 | + await github.rest.issues.updateComment({ |
| 81 | + owner: context.repo.owner, |
| 82 | + repo: context.repo.repo, |
| 83 | + comment_id: botComment.id, |
| 84 | + body: commentBody |
| 85 | + }); |
| 86 | + } else { |
| 87 | + await github.rest.issues.createComment({ |
| 88 | + owner: context.repo.owner, |
| 89 | + repo: context.repo.repo, |
| 90 | + issue_number: context.issue.number, |
| 91 | + body: commentBody |
| 92 | + }); |
| 93 | + } |
| 94 | +
|
| 95 | + # Test Elixir |
| 96 | + - run: mix format --check-formatted |
| 97 | + - run: mix deps.unlock --check-unused |
| 98 | + - run: mix compile --force --warnings-as-errors |
| 99 | + - run: mix test |
| 100 | + - run: test/prerelease.sh |
| 101 | + |
| 102 | + # Test JS |
76 | 103 | - run: npm run lint --prefix assets |
77 | | - - run: sudo apt-get install xvfb |
78 | | - - run: | |
| 104 | + - name: npm run test --prefix assets |
| 105 | + run: | |
| 106 | + sudo apt-get install xvfb |
79 | 107 | xvfb-run --auto-servernum npm run test --prefix assets |
80 | 108 | env: |
81 | 109 | CI: true |
82 | 110 |
|
83 | | - assets: |
84 | | - needs: [check_js] |
85 | | - runs-on: ubuntu-20.04 |
86 | | - if: github.ref_name == 'main' |
87 | | - steps: |
88 | | - - uses: actions/checkout@v3 |
89 | | - - uses: actions/setup-node@v3 |
90 | | - with: |
91 | | - node-version: ${{ env.node-version }} |
92 | | - - name: Cache npm dependencies |
93 | | - uses: actions/cache@v3 |
94 | | - with: |
95 | | - path: ~/.npm |
96 | | - key: ${{ runner.os }}-node-${{ hashFiles('asssets/package-lock.json') }} |
97 | | - - run: npm ci --prefix assets |
98 | | - - run: npm run build --prefix assets |
| 111 | + # Push updated assets if all good |
99 | 112 | - name: Push updated assets |
| 113 | + if: github.ref_name == 'main' |
100 | 114 | uses: stefanzweifel/git-auto-commit-action@v4 |
101 | 115 | with: |
102 | 116 | commit_message: Update assets |
103 | 117 | file_pattern: formatters |
| 118 | + |
| 119 | + elixir: |
| 120 | + runs-on: ubuntu-20.04 |
| 121 | + strategy: |
| 122 | + fail-fast: false |
| 123 | + matrix: |
| 124 | + include: |
| 125 | + # Test very old Elixir and Erlang |
| 126 | + - elixir: "1.14" |
| 127 | + otp: "25" |
| 128 | + # Test Erlang without -doc attribute support |
| 129 | + - elixir: "1.16" |
| 130 | + otp: "26" |
| 131 | + steps: |
| 132 | + - uses: actions/checkout@v3 |
| 133 | + |
| 134 | + - uses: erlef/setup-beam@v1 |
| 135 | + with: |
| 136 | + otp-version: ${{ matrix.otp }} |
| 137 | + elixir-version: ${{ matrix.elixir }} |
| 138 | + |
| 139 | + - run: mix deps.get |
| 140 | + - run: mix test |
| 141 | + - run: test/prerelease.sh |
0 commit comments