-
Notifications
You must be signed in to change notification settings - Fork 36
110 lines (97 loc) · 3.56 KB
/
Copy pathbuild.yml
File metadata and controls
110 lines (97 loc) · 3.56 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: "Build"
on:
issue_comment:
types: [ created ]
jobs:
trigger-comment:
if: github.event.issue.pull_request && contains(github.event.comment.body, '/build_and_test') && (github.actor == 'romerojosh' || github.actor == 'azrael417')
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: "Post trigger comment"
uses: actions/github-script@v7
with:
script: |
const workflowUrl = `${context.payload.repository.html_url}/actions/runs/${context.runId}`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `🚀 Build workflow triggered! [View run](${workflowUrl})`
});
build:
needs: trigger-comment
if: github.event.issue.pull_request && contains(github.event.comment.body, '/build_and_test') && (github.actor == 'romerojosh' || github.actor == 'azrael417')
strategy:
matrix:
include:
- name: "GPU build (NVHPC SDK 25.7, Ubuntu 22.04)"
dockerfile: "Dockerfile"
free_space: true
run_tests: false
- name: "GPU build (GNU, Ubuntu 22.04)"
dockerfile: "Dockerfile_gnu"
free_space: true
run_tests: false
- name: "CPU build (GNU, Ubuntu 22.04)"
dockerfile: "Dockerfile_gnu_cpuonly"
free_space: false
run_tests: true
name: ${{ matrix.name }}
runs-on: ubuntu-latest
steps:
- name: "Free disk space"
if: ${{ matrix.free_space }}
run: |
sudo rm -rf /usr/local/lib/android || true
sudo rm -rf /usr/share/dotnet || true
- name: "Retrieve PR info"
uses: actions/github-script@v7
id: pr-info
with:
script: |
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
core.setOutput('sha', pr.data.head.sha);
- name: "Checkout PR code"
uses: actions/checkout@v4
with:
persist-credentials: false
ref: ${{ steps.pr-info.outputs.sha }}
- name: "Set up Docker Buildx"
uses: docker/setup-buildx-action@v3
- name: "Build docker container"
run: |
docker build -t torchfort -f docker/${{ matrix.dockerfile }} .
- name: "Run tests"
if: ${{ matrix.run_tests }}
run: |
docker run -v ${PWD}/.github/scripts:/scripts -w /scripts --rm torchfort ./run_ci_tests.sh
result-comment:
needs: build
if: always() && github.event.issue.pull_request && contains(github.event.comment.body, '/build_and_test') && (github.actor == 'romerojosh' || github.actor == 'azrael417')
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: "Post result comment"
uses: actions/github-script@v7
with:
script: |
const workflowUrl = `${context.payload.repository.html_url}/actions/runs/${context.runId}`;
const success = '${{ needs.build.result }}' === 'success';
const message = success
? `✅ Build workflow passed! [View run](${workflowUrl})`
: `❌ Build workflow failed! [View run](${workflowUrl})`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message
});