v2 / .github / workflows / gen_vc_ci.yml
73 lines · 61 sloc · 2.38 KB · a48e8e28ecbbdb19e5632354f2eae61863fed90b
Raw
1name: VC gen
2
3on:
4 workflow_dispatch:
5 pull_request:
6 paths-ignore:
7 - '**.vv'
8 - '**.out'
9 - '**.md'
10 - '**.yml'
11 - '!**/gen_vc_ci.yml'
12 - 'cmd/tools/**'
13 - '!cmd/tools/builders/**.v'
14 push:
15 paths-ignore:
16 - '**.vv'
17 - '**.out'
18 - '**.md'
19 - '**.yml'
20 - '!**/gen_vc_ci.yml'
21 - 'cmd/tools/**'
22 - '!cmd/tools/builders/**.v'
23
24# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
25# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
26concurrency:
27 group: gen_vc-${{ github.workflow }}-${{ github.ref }}
28 cancel-in-progress: ${{ !contains(github.ref, 'master')}}
29
30jobs:
31 build-vc:
32 runs-on: ubuntu-latest
33 timeout-minutes: 20
34 steps:
35 - uses: actions/checkout@v6
36 - name: Build V
37 run: make -j4
38 - name: Regenerate v.c and v_win.c
39 run: |
40 git config --global user.email "[email protected]"
41 git config --global user.name "vlang-bot"
42
43 COMMIT_HASH="$(git rev-parse HEAD)"
44 COMMIT_MSG="$(git log -1 --oneline --pretty='%s' HEAD)"
45
46 rm -rf vc
47 ./v retry -- git clone --depth=1 "https://vlang-bot:${{ secrets.VLANG_BOT_SECRET }}@github.com/vlang/vc.git"
48
49 rm -rf vc/v.c vc/v_win.c
50 ./v -o vc/v.c -cross cmd/v
51 ./v -o vc/v_win.c -os windows -cc msvc cmd/v
52
53 sed -i "1s/^/#define V_COMMIT_HASH \"$COMMIT_HASH\"\n/" vc/v.c
54 sed -i "1s/^/#define V_COMMIT_HASH \"$COMMIT_HASH\"\n/" vc/v_win.c
55
56 # do some sanity checks for the generated v.c file:
57 grep 'Turned ON custom defines: no_backtrace,cross' vc/v.c
58 grep '#define CUSTOM_DEFINE_cross' vc/v.c
59
60 # ensure the generated C files for the compiler, are over 5000 lines long, as a safety measure
61 [ "$(wc -l < vc/v.c)" -gt 5000 ]
62 [ "$(wc -l < vc/v_win.c)" -gt 5000 ]
63
64 git -C vc add v.c v_win.c
65 git -C vc commit -m "[v:master] $COMMIT_HASH - $COMMIT_MSG"
66
67 # in case there are recent commits:
68 ./v retry -- git -C vc pull --rebase origin master
69 git -C vc log -3
70
71 - name: Deploy
72 if: github.event_name == 'push' && github.repository == 'vlang/v' && github.ref == 'refs/heads/master'
73 run: git -C vc push || true
74