-
-
Notifications
You must be signed in to change notification settings - Fork 381
922 lines (811 loc) · 31.1 KB
/
Copy pathmain.yml
File metadata and controls
922 lines (811 loc) · 31.1 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
name: CI
on:
push:
branches: [ master, dev, ci_testing, experiments, '*.*.x' ]
paths-ignore:
- '**.md'
- 'LICENSE'
- '.gitignore'
- 'resources/docs.html'
pull_request:
branches: [ master, dev ]
paths-ignore:
- '**.md'
- 'LICENSE'
- '.gitignore'
- 'resources/docs.html'
workflow_dispatch:
env:
LLVM_RELEASE_VERSION: 22.x
LLVM_RELEASE_VERSION_LINUX_MUSL: 21
LLVM_RELEASE_VERSION_OPENBSD: 20
LLVM_RELEASE_VERSION_NETBSD: 19
LLVM_DEV_VERSION: 22
# CACHE_INVALIDATION_SEED: '%Y-%m-%d' # Daily
CACHE_INVALIDATION_SEED: '%G-%V-1' # Weekly
jobs:
build-msvc:
name: Windows (x64) MSVC
runs-on: windows-2025
timeout-minutes: 30
defaults:
run:
shell: cmd
steps:
- uses: actions/checkout@v6
- uses: actions/cache@v5
with:
path: build/_deps
key: ${{ runner.os }}-llvm-${{ env.LLVM_RELEASE_VERSION }}-Release-Debug-${{ hashFiles('CMakeLists.txt', '.github/workflows/main.yml') }}
# set up the environment for Ninja
- uses: TheMrMilchmann/setup-msvc-dev@v4
with:
arch: x64
- name: CMake Build (Release)
run: |
cmake -B build-release -G Ninja -DCMAKE_BUILD_TYPE=Release -DC3_FETCH_LLVM=ON
cmake --build build-release --config Release
- name: Bundle (Windows Release)
shell: bash
run: ./scripts/tools/package_build.sh "./build-release/c3c.exe" "c3-windows-Release" "zip"
- uses: actions/upload-artifact@v7
with:
name: c3-windows-Release
path: c3-windows-Release.zip
- name: CMake Build (Debug)
run: |
cmake -B build-debug -G Ninja -DCMAKE_BUILD_TYPE=Debug -DC3_FETCH_LLVM=ON
cmake --build build-debug --config Debug
# We remove the GNU link tool so C3C picks up the MSVC link.exe
- name: Remove GNU Link
shell: bash
run: rm -f /usr/bin/link
- name: Cache FreeBSD Sysroot
uses: actions/cache@v5
with:
path: .cache
key: ${{ runner.os }}-freebsd-sysroot-15.0
- name: Run Unified Tests
shell: bash
run: ./scripts/tools/ci_tests.sh "./build-debug/c3c.exe"
- name: Bundle (Windows Debug)
shell: bash
run: ./scripts/tools/package_build.sh "./build-debug/c3c.exe" "c3-windows-Debug" "zip"
- uses: actions/upload-artifact@v7
with:
name: c3-windows-Debug
path: c3-windows-Debug.zip
- name: Cache NSIS
id: cache-nsis
uses: actions/cache@v5
with:
path: C:\Program Files (x86)\NSIS
key: ${{ runner.os }}-nsis-3.12
- name: Setup NSIS & Compile Installers
shell: bash
run: |
if [ "${{ steps.cache-nsis.outputs.cache-hit }}" != "true" ]; then
choco install nsis -y
curl -L -o EnVar-Plugin.zip "https://github.com/GsNSIS/EnVar/releases/download/v0.3.1/EnVar-Plugin.zip"
7z x EnVar-Plugin.zip -o"C:\Program Files (x86)\NSIS" -y
fi
curl -sSfL -o MANUAL.md https://c3-lang.org/all.md
curl -sSfL -o c3fmt.exe https://github.com/lmichaudel/c3fmt/releases/latest/download/c3fmt-windows.exe
export PATH="/c/Program Files (x86)/NSIS/Bin:/c/Program Files (x86)/NSIS:$PATH"
MSYS_NO_PATHCONV=1 makensis /DINSTALLER_NAME="c3-windows-setup-Release.exe" /DBUILD_DIR=build-release resources/nsis/installer.nsi
MSYS_NO_PATHCONV=1 makensis /DINSTALLER_NAME="c3-windows-setup-Debug.exe" /DBUILD_DIR=build-debug resources/nsis/installer.nsi
- uses: actions/upload-artifact@v7
with:
name: c3-windows-setup-Release
path: resources/nsis/c3-windows-setup-Release.exe
- uses: actions/upload-artifact@v7
with:
name: c3-windows-setup-Debug
path: resources/nsis/c3-windows-setup-Debug.exe
build-msys2:
name: Windows (x64) ${{ matrix.sys }}
runs-on: windows-2025
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- { sys: MINGW64, prefix: /mingw64 }
- { sys: CLANG64, prefix: /clang64 }
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v6
- uses: msys2/setup-msys2@v2
with:
msystem: ${{matrix.sys}}
update: true
cache: true
pacboy: >-
cmake:p
ninja:p
llvm:p
lld:p
clang:p
toolchain:p
python:p
git:p
zlib:p
zstd:p
libxml2:p
# (MINGW64) Force LLD as the linker to resolve __imp_ symbol thunking issues from
# static LLVM archives (LNK4217), which the GNU linker (ld) cannot resolve automatically.
- name: CMake Build
run: |
cmake -B build -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_LINKER=lld -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" -DC3_LINK_DYNAMIC=OFF -DLLVM_DIR=${{matrix.prefix}}/lib/cmake/llvm -DC3_LLD_DIR=${{matrix.prefix}}/lib/
cmake --build build
- name: Cache FreeBSD Sysroot
uses: actions/cache@v5
with:
path: .cache
key: ${{ runner.os }}-freebsd-sysroot-15.0
- name: Run Unified Tests
run: ./scripts/tools/ci_tests.sh "./build/c3c"
build-linux:
name: Linux (x64) Ubuntu
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: Get current date context
id: date
run: echo "date=$(date +'${{ env.CACHE_INVALIDATION_SEED }}')" >> $GITHUB_OUTPUT
- name: Cache APT archives
uses: actions/cache@v5
with:
path: apt-cache
key: apt-cache-${{ runner.os }}-${{ steps.date.outputs.date }}
- run: |
mkdir -p apt-cache/partial
for i in 1 2 3; do sudo apt-get update && break || sleep 2; done
for i in 1 2 3; do sudo apt-get install -y -o dir::cache::archives="$(pwd)/apt-cache" --fix-missing zlib1g zlib1g-dev python3 ninja-build curl libcurl4-openssl-dev opensbi qemu-system-misc u-boot-qemu gcc-riscv64-unknown-elf libx11-dev libxrandr-dev libxinerama-dev libxi-dev libxxf86vm-dev libxcursor-dev && break || sleep 2; done
sudo chown -R $USER:$USER apt-cache
- name: CMake Build (Release)
run: |
cmake -B build-release -G Ninja -DCMAKE_BUILD_TYPE=Release -DC3_FETCH_LLVM=ON
cmake --build build-release
- name: Bundle & Upload (Linux Release)
run: |
bash ./scripts/tools/package_build.sh "./build-release/c3c" "c3-linux-Release" "tar"
- uses: actions/upload-artifact@v7
with:
name: c3-linux-Release
path: c3-linux-Release.tar.gz
- name: CMake Build (Debug)
run: |
cmake -B build-debug -G Ninja -DCMAKE_BUILD_TYPE=Debug -DC3_FETCH_LLVM=ON
cmake --build build-debug
- name: Cache FreeBSD Sysroot
uses: actions/cache@v5
with:
path: .cache
key: ${{ runner.os }}-freebsd-sysroot-15.0
- name: Run Unified Tests
run: ./scripts/tools/ci_tests.sh "./build-debug/c3c"
- name: Embedded/QEMU Tests
run: |
cd resources/examples/embedded/riscv-qemu
make C3C_PATH=../../../../build-debug/ run
- name: Bundle & Upload (Linux Debug)
run: |
bash ./scripts/tools/package_build.sh "./build-debug/c3c" "c3-linux-Debug" "tar"
- uses: actions/upload-artifact@v7
with:
name: c3-linux-Debug
path: c3-linux-Debug.tar.gz
test-emscripten-32bit:
name: Emscripten
needs: build-linux
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
build_type: [Debug]
steps:
- uses: actions/checkout@v6
- uses: actions/download-artifact@v8
with:
name: c3-linux-${{matrix.build_type}}
path: bin
- name: Extract C3
run: |
tar -xzf bin/c3-linux-${{matrix.build_type}}.tar.gz -C bin
# The package_build.sh creates a 'c3' directory inside the tar
chmod +x bin/c3/c3c
- name: Setup Emscripten
run: |
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
echo "$GITHUB_WORKSPACE/emsdk" >> $GITHUB_PATH
echo "$GITHUB_WORKSPACE/emsdk/upstream/emscripten" >> $GITHUB_PATH
- name: Run Emscripten Tests
run: ./scripts/tools/emscripten_tests.sh "./bin/c3/c3c"
build-linux-musl-static:
name: Linux (x64) musl Static
runs-on: ubuntu-24.04
container:
image: alpine:3.23
steps:
- name: Prepare Git
run: |
apk add --no-cache git
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- uses: actions/checkout@v6
- name: Install dependencies
run: |
apk update
apk add \
build-base bash cmake ninja python3 linux-headers \
zlib-dev zlib-static zstd-dev zstd-static curl-dev curl-static \
openssl-libs-static brotli-static nghttp2-static libpsl-static \
libidn2-static libunistring-static nghttp3-static c-ares-dev \
curl-dev openssl-dev brotli-dev libpsl-dev libidn2-dev \
libunistring-dev nghttp2-dev nghttp3-dev c-ares-dev
- name: CMake Build (static musl Release)
run: |
cmake -B build-release -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DC3_FETCH_LLVM=ON \
-DC3_LINK_DYNAMIC=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_EXE_LINKER_FLAGS="-static -static-libstdc++ -static-libgcc"
cmake --build build-release
- name: Bundle (Release)
run: bash ./scripts/tools/package_build.sh "./build-release/c3c" "c3-linux-static-Release" "tar"
- uses: actions/upload-artifact@v7
with:
name: c3-linux-static-Release
path: c3-linux-static-Release.tar.gz
- name: CMake Build (static musl Debug)
run: |
cmake -B build-debug -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DC3_FETCH_LLVM=ON \
-DC3_LINK_DYNAMIC=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_EXE_LINKER_FLAGS="-static -static-libstdc++ -static-libgcc"
cmake --build build-debug
- name: Verify Static
run: |
ldd build-debug/c3c || true
file build-debug/c3c
build-debug/c3c --version
- name: Run Unified Tests
run: ./scripts/tools/ci_tests.sh "./build-debug/c3c"
- name: Bundle (Debug)
run: bash ./scripts/tools/package_build.sh "./build-debug/c3c" "c3-linux-static-Debug" "tar"
- uses: actions/upload-artifact@v7
with:
name: c3-linux-static-Debug
path: c3-linux-static-Debug.tar.gz
build-linux-alpine:
name: Linux (x64) Alpine Dynamic
runs-on: ubuntu-24.04
container:
image: alpine:3.23
steps:
- name: Prepare Git
run: |
apk add --no-cache git
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- uses: actions/checkout@v6
- name: Get current date context
id: date
run: echo "date=$(date +'${{ env.CACHE_INVALIDATION_SEED }}')" >> $GITHUB_OUTPUT
#https://wiki.alpinelinux.org/wiki/Local_APK_cache
- name: Prepare real apk cache directory + symlink
run: |
mkdir -p /var/cache/apk
ln -sf /var/cache/apk /etc/apk/cache
- name: Cache APK downloaded packages (daily)
uses: actions/cache@v5
with:
path: /var/cache/apk
key: apk-pkgs-${{ runner.os }}-alpine-3.23-${{ steps.date.outputs.date }}
restore-keys: |
apk-pkgs-${{ runner.os }}-alpine-3.23-
- name: Install dependencies
run: |
V=${{env.LLVM_RELEASE_VERSION_LINUX_MUSL}}
for i in 1 2 3; do apk update && break || sleep 2; done
for i in 1 2 3; do \
apk add \
build-base bash cmake ninja \
tar zstd \
curl-dev \
llvm${V}-dev \
llvm${V}-static \
llvm${V}-gtest \
lld${V}-dev \
lld${V}-libs && break || sleep 2; \
done
- name: CMake Build (Release)
run: |
cmake -B build-release -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DC3_FETCH_LLVM=OFF \
-DLLVM_ENABLE_LIBXML2=OFF \
-DC3_LINK_DYNAMIC=ON
cmake --build build-release
- name: Bundle & Upload (Alpine Release)
run: bash ./scripts/tools/package_build.sh "./build-release/c3c" "c3-linux-musl-Release" "tar"
- uses: actions/upload-artifact@v7
with:
name: c3-linux-musl-Release
path: c3-linux-musl-Release.tar.gz
- name: CMake Build (Debug)
run: |
cmake -B build-debug -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DC3_FETCH_LLVM=OFF \
-DLLVM_ENABLE_LIBXML2=OFF \
-DC3_LINK_DYNAMIC=ON
cmake --build build-debug
- name: Run Unified Tests
run: ./scripts/tools/ci_tests.sh "./build-debug/c3c"
- name: Bundle & Upload (Alpine Debug)
run: bash ./scripts/tools/package_build.sh "./build-debug/c3c" "c3-linux-musl-Debug" "tar"
- uses: actions/upload-artifact@v7
with:
name: c3-linux-musl-Debug
path: c3-linux-musl-Debug.tar.gz
build-mac:
name: macOS (aarch64)
runs-on: macos-latest
steps:
- uses: actions/checkout@v6
- name: CMake Build (Release)
run: |
cmake -B build-release -G Ninja -DCMAKE_BUILD_TYPE=Release -DC3_FETCH_LLVM=ON
cmake --build build-release
- name: Bundle & Upload (Mac Release)
run: bash ./scripts/tools/package_build.sh "./build-release/c3c" "c3-macos-Release" "zip"
- uses: actions/upload-artifact@v7
with:
name: c3-macos-Release
path: c3-macos-Release.zip
- name: CMake Build (Debug)
run: |
cmake -B build-debug -G Ninja -DCMAKE_BUILD_TYPE=Debug -DC3_FETCH_LLVM=ON
cmake --build build-debug
- name: Cache FreeBSD Sysroot
uses: actions/cache@v5
with:
path: .cache
key: ${{ runner.os }}-freebsd-sysroot-15.0
- name: Run Unified Tests
run: ./scripts/tools/ci_tests.sh "./build-debug/c3c"
- name: Build Lib (Mac Debug)
run: |
cd resources/testproject
../../build-debug/c3c build hello_world_lib -vv --trust=full
- name: Bundle & Upload (Mac Debug)
run: bash ./scripts/tools/package_build.sh "./build-debug/c3c" "c3-macos-Debug" "zip"
- uses: actions/upload-artifact@v7
with:
name: c3-macos-Debug
path: c3-macos-Debug.zip
build-openbsd:
name: OpenBSD (x64) ${{ matrix.version }}
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
version: ['7.9']
steps:
- uses: actions/checkout@v6
- name: Setup OpenBSD VM
uses: cross-platform-actions/action@master
with:
operating_system: openbsd
version: ${{ matrix.version }}
cpu_count: 4
memory: 6G
- name: Install Dependencies
shell: cpa.sh {0}
run: |
echo "Testing OpenBSD mirrors..."
for m in "https://cloudflare.cdn.openbsd.org/pub/OpenBSD" "https://cdn.openbsd.org/pub/OpenBSD" "https://mirror.planetunix.net/pub/OpenBSD" "https://ftp.usa.openbsd.org/pub/OpenBSD"; do
if curl -s -f -I -L --connect-timeout 5 --max-time 10 "${m}/${{ matrix.version }}/packages/amd64/" > /dev/null; then
echo "Selected mirror: ${m}"
echo "${m}" | sudo tee /etc/installurl
break
fi
done
for i in 1 2 3; do
sudo pkg_add ninja cmake llvm%${{ env.LLVM_RELEASE_VERSION_OPENBSD }} bash && break || sleep 5
done
- name: Build (Release)
shell: cpa.sh {0}
run: |
export MALLOC_OPTIONS=j
cmake -B build-release -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build-release
- name: Build (Debug)
shell: cpa.sh {0}
run: |
export MALLOC_OPTIONS=j
cmake -B build-debug -G Ninja -DCMAKE_BUILD_TYPE=Debug
cmake --build build-debug
- name: Run Tests
shell: cpa.sh {0}
run: |
export MALLOC_OPTIONS=j
ulimit -d $(ulimit -Hd) || true
./scripts/tools/ci_tests.sh build-debug/c3c
- name: Package
shell: cpa.sh {0}
run: |
export MALLOC_OPTIONS=j
./scripts/tools/package_build.sh "./build-release/c3c" "c3-openbsd-Release" "tar"
./scripts/tools/package_build.sh "./build-debug/c3c" "c3-openbsd-Debug" "tar"
- name: Upload Artifacts (Release)
uses: actions/upload-artifact@v7
with:
name: c3-openbsd-Release
path: c3-openbsd-Release.tar.gz
- name: Upload Artifacts (Debug)
uses: actions/upload-artifact@v7
with:
name: c3-openbsd-Debug
path: c3-openbsd-Debug.tar.gz
build-netbsd:
name: NetBSD (x64) ${{ matrix.version }}
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
version: ['10.1']
steps:
- uses: actions/checkout@v6
- name: Setup NetBSD VM
uses: cross-platform-actions/action@master
with:
operating_system: netbsd
version: ${{ matrix.version }}
cpu_count: 4
memory: 6G
- name: Install Dependencies
shell: cpa.sh {0}
run: |
# Install dependencies, select best mirror
export PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
sudo mkdir -p /usr/pkg/etc/pkgin
MIRROR_PATH="pub/pkgsrc/packages/NetBSD/amd64/10.1/All"
WORKING_MIRRORS=""
echo "Testing mirrors..."
for m in "http://cdn.NetBSD.org/$MIRROR_PATH" "http://ftp.jaist.ac.jp/$MIRROR_PATH" "http://ftp.NetBSD.org/$MIRROR_PATH" "http://ftp.fr.NetBSD.org/$MIRROR_PATH" "https://mirror.planetunix.net/$MIRROR_PATH"; do
if curl -s -f -I -L --connect-timeout 5 --max-time 10 "$m/pkg_summary.bz2" > /dev/null; then
echo "OK: $m"
WORKING_MIRRORS="${WORKING_MIRRORS}${m}/\n"
fi
done
if [ -n "$WORKING_MIRRORS" ]; then
printf "$WORKING_MIRRORS" | sudo tee /usr/pkg/etc/pkgin/repositories.conf
else
echo "No mirrors responded, using main site as fallback."
echo "http://ftp.NetBSD.org/$MIRROR_PATH/" | sudo tee /usr/pkg/etc/pkgin/repositories.conf
fi
for i in 1 2 3; do
sudo pkgin -y update && \
sudo pkgin -y install cmake gcc14 ninja-build bash \
"llvm>=${{ env.LLVM_RELEASE_VERSION_NETBSD }}" \
"clang>=${{ env.LLVM_RELEASE_VERSION_NETBSD }}" \
"lld>=${{ env.LLVM_RELEASE_VERSION_NETBSD }}" && break || sleep 5
done
- name: Build (Release)
shell: cpa.sh {0}
run: |
export PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
export CC=clang
export CXX=clang++
cmake -B build-release -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build-release
- name: Build (Debug)
shell: cpa.sh {0}
run: |
export PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
export CC=clang
export CXX=clang++
cmake -B build-debug -G Ninja -DCMAKE_BUILD_TYPE=Debug
cmake --build build-debug
- name: Run Tests
shell: cpa.sh {0}
run: |
export PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
./scripts/tools/ci_tests.sh build-debug/c3c
- name: Package
shell: cpa.sh {0}
run: |
export PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
./scripts/tools/package_build.sh "./build-release/c3c" "c3-netbsd-Release" "tar"
./scripts/tools/package_build.sh "./build-debug/c3c" "c3-netbsd-Debug" "tar"
- name: Upload Artifacts (Release)
uses: actions/upload-artifact@v7
with:
name: c3-netbsd-Release
path: c3-netbsd-Release.tar.gz
- name: Upload Artifacts (Debug)
uses: actions/upload-artifact@v7
with:
name: c3-netbsd-Debug
path: c3-netbsd-Debug.tar.gz
build-with-docker:
name: LLVM ${{ matrix.llvm_version }} Compatibility
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
llvm_version: [19, 20]
steps:
- uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and cache Docker image
uses: docker/build-push-action@v7
with:
context: ./docker
build-args: |
LLVM_VERSION=${{ matrix.llvm_version }}
UBUNTU_VERSION=24.04
CMAKE_VERSION=3.20.0
tags: c3c-builder:latest
outputs: type=docker,dest=/tmp/c3c-builder.tar
cache-from: type=gha,scope=build-with-docker-${{ matrix.llvm_version }}
cache-to: type=gha,mode=max,scope=build-with-docker-${{ matrix.llvm_version }}
env:
DOCKER_BUILD_SUMMARY: false
- name: Load Docker image
run: docker load -i /tmp/c3c-builder.tar
- name: Build C3 in Docker
run: |
rm -rf build bin
mkdir -p build bin
chmod -R 777 build bin
docker run --rm \
-v "$(pwd):/home/c3c/source" \
-w /home/c3c/source \
c3c-builder:latest \
bash -c "git config --global --add safe.directory /home/c3c/source && \
cmake -S . -B build \
-G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER=clang-${{ matrix.llvm_version }} \
-DCMAKE_CXX_COMPILER=clang++-${{ matrix.llvm_version }} \
-DCMAKE_LINKER=lld-${{ matrix.llvm_version }} \
-DCMAKE_OBJCOPY=llvm-objcopy-${{ matrix.llvm_version }} \
-DCMAKE_STRIP=llvm-strip-${{ matrix.llvm_version }} \
-DCMAKE_DLLTOOL=llvm-dlltool-${{ matrix.llvm_version }} \
-DC3_LLVM_VERSION=auto && \
cmake --build build && \
cp -r build/c3c build/lib bin"
- name: Run Unified Tests
run: |
docker run --rm \
-u 0 \
-v "$(pwd):/home/c3c/source" \
-w /home/c3c/source \
c3c-builder \
bash -c "./scripts/tools/ci_tests.sh ./bin/c3c"
build-linux-llvm23:
if: false
name: Linux (x64) LLVM 23
runs-on: ubuntu-24.04
timeout-minutes: 30
continue-on-error: true
steps:
- uses: actions/checkout@v6
- name: Install LLVM 23 from apt.llvm.org
run: |
sudo mkdir -p /etc/apt/keyrings
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/llvm.gpg
echo "deb [signed-by=/etc/apt/keyrings/llvm.gpg] http://apt.llvm.org/noble/ llvm-toolchain-noble main" | sudo tee /etc/apt/sources.list.d/llvm.list
sudo apt-get update
sudo apt-get install -y \
llvm-23-dev \
clang-23 \
lld-23 \
liblld-23-dev \
libpolly-23-dev \
libclang-23-dev \
zlib1g-dev \
ninja-build \
python3 \
libx11-dev libxrandr-dev libxinerama-dev libxi-dev libxxf86vm-dev libxcursor-dev # for raylib6
- name: CMake Build
run: |
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Debug
cmake --build build
- name: Run Unified Tests
run: ./scripts/tools/ci_tests.sh "./build/c3c"
build-nix:
name: Nix (${{ matrix.nixpkgs }})
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
build_type: [ Debug ]
nixpkgs: [ Lock, Latest ]
steps:
- uses: actions/checkout@v6
- uses: cachix/install-nix-action@v31
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Update flake
if: matrix.nixpkgs == 'Latest'
run: nix flake update
- name: CMake build and run Unified Tests
run: |
CHECK_NAME=".#c3c-checks"
if [[ ${{ matrix.build_type }} = "Debug" ]]; then CHECK_NAME=".#c3c-debug-checks"; fi
nix build -L "$CHECK_NAME"
build-android:
name: Android (${{ matrix.architecture }})
strategy:
fail-fast: false
matrix:
architecture: [ aarch64, x86_64 ]
include:
- architecture: aarch64
runner: ubuntu-24.04-arm
- architecture: x86_64
runner: ubuntu-24.04
runs-on: ${{matrix.runner}}
container:
image: termux/termux-docker:${{matrix.architecture}}
volumes:
- /tmp/node20:/__e/node20
- /tmp/node24:/__e/node24
env:
TERMUX_MAIN_PACKAGE_FORMAT: debian
ANDROID_ROOT: /system
ANDROID_DATA: /data
PREFIX: /data/data/com.termux/files/usr
HOME: /data/data/com.termux/files/home
PATH: /data/data/com.termux/files/usr/bin
TMPDIR: /data/data/com.termux/files/usr/tmp
LANG: en_US.UTF-8
TZ: UTC
steps:
- name: select termux mirror
run: |
for m in \
"https://termux.mentality.rip/termux-main" \
"https://ftp.agdsn.de/termux/termux-main" \
"https://linux.domainesia.com/applications/termux/termux-main"
do
echo "Trying mirror: $m"
printf "deb %s stable main\n" "$m" > "${PREFIX}/etc/apt/sources.list"
if /entrypoint.sh pkg update -y; then
echo "Selected mirror: $m"
exit 0
fi
done
echo "All mirrors failed"
exit 1
- name: prepare termux
run: |
ln -sf ${PREFIX}/etc/termux/mirrors/default ${PREFIX}/etc/termux/chosen_mirrors
# Ensure root can execute Termux binaries (the new image has them as 700)
chmod -R 755 ${PREFIX}/bin || true
for i in 1 2; do /entrypoint.sh pkg update && break || sleep 5; done
/entrypoint.sh bash -c "yes | pkg upgrade -y"
for i in 1 2; do /entrypoint.sh pkg install -y nodejs-lts tar git && break || sleep 5; done
# Fix permissions again for newly installed packages and add compatibility symlinks
chmod -R 755 ${PREFIX}/bin
mkdir -p /usr/bin /bin || true
ln -sf ${PREFIX}/bin/env /usr/bin/env || true
ln -sf ${PREFIX}/bin/bash /usr/bin/bash || true
ln -sf ${PREFIX}/bin/sh /bin/sh || true
# Ensure TMPDIR exists and is writable
mkdir -p ${TMPDIR} /tmp || true
chmod 1777 ${TMPDIR} || true
# Symlink Termux node to where GHA expects it
mkdir -p /__e/node20/bin /__e/node24/bin || true
ln -sf ${PREFIX}/bin/node /__e/node20/bin/node || true
ln -sf ${PREFIX}/bin/node /__e/node24/bin/node || true
- name: Get current date context
id: date
run: echo "date=$(date +'${{ env.CACHE_INVALIDATION_SEED }}')" >> $GITHUB_OUTPUT
- name: Cache Termux packages
uses: actions/cache@v5
with:
path: /data/data/com.termux/cache/apt/archives/
key: termux-cache-${{ matrix.architecture }}-${{ steps.date.outputs.date }}
- uses: actions/checkout@v6
- name: fix permissions after checkout
run: chown -R 1000:1000 .
- name: setup
run: |
for i in 1 2; do \
/entrypoint.sh pkg update -y && \
/entrypoint.sh pkg install -y llvm binutils libgc build-essential cmake git libedit zlib clang make mlir llvm-tools libpolly python libllvm-static && break || sleep 10; \
done
- name: build (Release)
run: |
cmake -B build-release -DCMAKE_BUILD_TYPE=Release
cmake --build build-release
- name: Bundle Release
run: |
chmod +x ./scripts/tools/package_build.sh
bash ./scripts/tools/package_build.sh "./build-release/c3c" "c3-android-${{matrix.architecture}}-Release" "tar"
- name: upload artifacts (Release)
uses: actions/upload-artifact@v7
with:
name: c3-android-${{matrix.architecture}}-Release
path: c3-android-${{matrix.architecture}}-Release.tar.gz
- name: build (Debug)
run: |
cmake -B build-debug -DCMAKE_BUILD_TYPE=Debug
cmake --build build-debug
- name: Run Unified Tests
run: bash ./scripts/tools/ci_tests.sh "./build-debug/c3c" "android"
- name: Bundle Debug
run: |
chmod +x ./scripts/tools/package_build.sh
bash ./scripts/tools/package_build.sh "./build-debug/c3c" "c3-android-${{matrix.architecture}}-Debug" "tar"
- name: upload artifacts (Debug)
uses: actions/upload-artifact@v7
with:
name: c3-android-${{matrix.architecture}}-Debug
path: c3-android-${{matrix.architecture}}-Debug.tar.gz
release:
runs-on: ubuntu-slim
needs: [build-msvc, build-linux, build-mac, build-linux-alpine, build-openbsd, build-netbsd, build-android, build-linux-musl-static]
if: github.ref == 'refs/heads/master' || endsWith(github.ref, '.x')
permissions:
contents: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NAME: ""
TAG_NAME: ""
steps:
- uses: actions/checkout@v6
- uses: actions/download-artifact@v8
- name: Prepare Assets
run: |
for config in Release Debug; do
for platform in windows macos linux linux-musl linux-static openbsd netbsd android-aarch64 android-x86_64 windows-setup; do
# Windows and macOS produce zip, others tar.gz
if [ "$platform" = "windows" ] || [ "$platform" = "macos" ]; then
ext="zip"
elif [ "$platform" = "windows-setup" ]; then
ext="exe"
else
ext="tar.gz"
fi
src="c3-${platform}-${config}/c3-${platform}-${config}.${ext}"
dst="c3-${platform}"
[ "$config" = "Debug" ] && dst="${dst}-debug"
dst="${dst}.${ext}"
mv "$src" "$dst" || true
done
done
- name: Set Release Names
run: |
if [ "${{ github.ref }}" = "refs/heads/master" ]; then
echo "TAG_NAME=latest-prerelease-tag" >> $GITHUB_ENV
echo "RELEASE_NAME=latest-prerelease-$(date +'%Y%m%d-%H%M')" >> $GITHUB_ENV
else
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
echo "TAG_NAME=${BRANCH_NAME}-latest" >> $GITHUB_ENV
echo "RELEASE_NAME=${BRANCH_NAME}-latest" >> $GITHUB_ENV
fi
- run: gh release delete ${{ env.TAG_NAME }} --cleanup-tag -y || true
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag: ${{ env.TAG_NAME }}
name: ${{ env.RELEASE_NAME }}
prerelease: true
allowUpdates: true
removeArtifacts: true
artifacts: "*.zip,*.tar.gz,*.exe"