-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (78 loc) · 3.06 KB
/
free-test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Run free test
on:
issue_comment:
types: [ created ]
jobs:
run_free_test:
if: github.event.issue.pull_request == null && startsWith(github.event.comment.body, '```text:freetest') && github.event.comment.user.login == 'YuukiToriyama'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get head commit
uses: actions/github-script@v7.0.1
id: get-head-commit
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const commit = await github.rest.git.getRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "heads/main"
})
return commit.data.object.sha
- name: Install wasm-pack
working-directory: wasm
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Build wasm module
working-directory: wasm
run: wasm-pack build --target nodejs --scope toriyama
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Run free test
id: run-free-test
continue-on-error: true
run: echo '${{ github.event.comment.body }}' | grep -v '```' | node .github/scripts/free_test.js
- name: Read test result
id: read-test-result
uses: juliangruber/read-file-action@v1.1.7
with:
path: ./test_result.md
- name: Comment
uses: actions/github-script@v7.0.1
if: steps.run-free-test.outcome == 'success'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `${{ steps.read-test-result.outputs.content }}\n### テストに使用したリビジョン\n${{ steps.get-head-commit.outputs.result }}`
})
await github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: ${{ github.event.comment.id }},
content: "rocket"
})
- name: Comment(on error)
uses: actions/github-script@v7.0.1
if: steps.run-free-test.outcome == 'failure'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `:bomb: テストが失敗しました\n\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`
})
await github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: ${{ github.event.comment.id }},
content: "eyes"
})