-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (71 loc) · 3.03 KB
/
c-cpp.yml
File metadata and controls
73 lines (71 loc) · 3.03 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
name: "Github Actions For Compiling cpp files and Checking if they are can pass test cases"
on: # rebuild any PRs and main branch changes
pull_request:
push:
branches:
- main
jobs:
# 変更または新規のcppファイルのパスを取得する
get-changed-files:
runs-on: ubuntu-latest
outputs:
changed_files: ${{ steps.changed-files.outputs.all_changed_files }}
any_changed: ${{ steps.changed-files.outputs.any_changed }}
steps:
- name: Checkout (GitHub)
uses: actions/checkout@v3
# tj-actions/changed-filesを動作させるために指定している
with:
fetch-depth: 0
- name: Get changed files
uses: tj-actions/changed-files@v39
id: changed-files
# パスに関係なく変更があった or 追加されたcppファイルのパスを全て取得する
with:
files: |
**.cpp
files_separator: "\n"
- name: Output changed files
run: echo ${{ steps.changed-files.outputs.all_changed_files }}
# devcontainerと同等のコンテナを起動 & 変更があったcppファイルがあればコンパイルできるかチェックする
run-devcontainer-and-compile-cpp-files:
runs-on: ubuntu-latest
needs: [get-changed-files]
# permissionsを指定しないとGitHub Container Registryにpushできない
permissions:
contents: read
packages: write
steps:
# 現状以下のissueで要望はあがっているが、jobをまたぐと別の仮想マシン上で動作する都合上、
# jobごとにチェックアウトしないといけないらしい
# https://github.com/actions/checkout/issues/19
- name: Checkout (GitHub)
uses: actions/checkout@v3
# tj-actions/changed-filesを動作させるために指定している
with:
fetch-depth: 0
# workflowの高速化のため、コンテナをGHCR上にアップ
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Check the changed files are able to be compiled
uses: devcontainers/ci@v0.3
env:
WORKSPACE_PATH: /workspaces/Atcoder/
with:
imageName: ghcr.io/yuyahy/atcoder-devcontainer
# TODO: atestのaliasが有効になっていない件の確認
# TODO: コンパイルオプションをaliasとまとめられないか検討
runCmd: |
for i in ${{ needs.get-changed-files.outputs.changed_files }}; do
echo $i
cd $(dirname ${WORKSPACE_PATH}$i)
pwd
ls -la
g++-12 -Wfatal-errors -Wall -Wextra -Wshadow -Wconversion -Wfloat-equal -ftrapv -fsanitize=address,undefined -fno-omit-frame-pointer -fno-sanitize-recover -std=gnu++20 -I /tmp/ac-library "${WORKSPACE_PATH}$i"
done
env: |
WORKSPACE_PATH