Skip to content

Commit ef9bfb7

Browse files
committed
ci: Add github actions workflows
1 parent a52a933 commit ef9bfb7

File tree

2 files changed

+294
-0
lines changed

2 files changed

+294
-0
lines changed

.github/workflows/build.yaml

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
name: "Build"
2+
3+
on: [push]
4+
5+
jobs:
6+
# Native linux builds
7+
linux:
8+
name: 'Linux: ${{ matrix.os }}: ${{ matrix.compiler.vendor }}'
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
os:
14+
- ubuntu-22.04
15+
- ubuntu-24.04
16+
compiler:
17+
# The NetSurf build system can't find LLVM AR (it looks for it
18+
# in /usr/lib instead of /usr/bin:
19+
# `make: /usr/lib/llvm-ar: No such file or directory`).
20+
# So we need to make it explicit for llvm.
21+
- { vendor: gnu, CC: gcc, AR: ar }
22+
- { vendor: llvm, CC: clang, AR: llvm-ar }
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v6
27+
with:
28+
fetch-depth: 1
29+
30+
- name: apt-get install packages
31+
run: sudo apt-get update -qq &&
32+
sudo apt-get install --no-install-recommends -y
33+
bison
34+
build-essential
35+
check
36+
clang
37+
flex
38+
git
39+
gperf
40+
llvm
41+
pkg-config
42+
43+
- name: Get env.sh
44+
run: |
45+
mkdir projects
46+
wget -O projects/env.sh https://raw.githubusercontent.com/netsurf-browser/netsurf/refs/heads/master/docs/env.sh
47+
48+
- name: Build and install project deps
49+
env:
50+
CC: ${{ matrix.compiler.CC }}
51+
AR: ${{ matrix.compiler.AR }}
52+
TARGET: ${{ github.event.repository.name }}
53+
run: |
54+
export TARGET_WORKSPACE="$(pwd)/projects"
55+
source projects/env.sh
56+
ns-clone -d -s -b ${GITHUB_REF_NAME}
57+
ns-make-libs install
58+
59+
- name: Build Library
60+
env:
61+
CC: ${{ matrix.compiler.CC }}
62+
AR: ${{ matrix.compiler.AR }}
63+
TARGET: ${{ github.event.repository.name }}
64+
run: |
65+
export TARGET_WORKSPACE="$(pwd)/projects"
66+
source projects/env.sh
67+
make -j"$(nproc)"
68+
69+
- name: Unit Tests
70+
env:
71+
CC: ${{ matrix.compiler.CC }}
72+
AR: ${{ matrix.compiler.AR }}
73+
TARGET: ${{ github.event.repository.name }}
74+
run: |
75+
export TARGET_WORKSPACE="$(pwd)/projects"
76+
source projects/env.sh
77+
make test
78+
79+
# Cross compile using toolchains built in the toolchains repo.
80+
cross:
81+
name: 'Cross: ${{ matrix.toolchain }}' # ATM toolchain unique across builds
82+
runs-on: ubuntu-24.04 # Matches toolchains workflow
83+
strategy:
84+
fail-fast: false
85+
matrix:
86+
toolchain:
87+
- arm-riscos-gnueabi
88+
- arm-unknown-riscos
89+
- i686-w64-mingw32
90+
- m5475-atari-mint
91+
- m68k-atari-mint
92+
- m68k-unknown-amigaos
93+
- ppc-amigaos
94+
- x86_64-w64-mingw32
95+
96+
steps:
97+
- name: Checkout repository
98+
uses: actions/checkout@v6
99+
with:
100+
fetch-depth: 1
101+
102+
- name: apt-get install packages
103+
run: sudo apt-get update -qq &&
104+
sudo apt-get install --no-install-recommends -y
105+
bison
106+
build-essential
107+
ccache
108+
check
109+
clang
110+
flex
111+
git
112+
gperf
113+
jlha-utils
114+
libcurl4-openssl-dev
115+
libhtml-parser-perl
116+
libjpeg-dev
117+
libpng-dev
118+
librsvg2-dev
119+
llvm
120+
nsis
121+
pkg-config
122+
123+
- name: Get env.sh
124+
run: |
125+
mkdir projects
126+
wget -O projects/env.sh https://raw.githubusercontent.com/netsurf-browser/netsurf/refs/heads/master/docs/env.sh
127+
128+
129+
- name: ccache
130+
uses: hendrikmuhs/[email protected]
131+
with:
132+
key: ${{ github.job }}-${{ matrix.toolchain }}
133+
max-size: 128M
134+
135+
# look for toolchain for this branch name first, then default to master
136+
- name: Download toolchain
137+
run: |
138+
set -e
139+
140+
TOOLCHAIN_NAME="${{ matrix.toolchain }}"
141+
BRANCH_NAME="${{ github.ref_name }}"
142+
143+
# Function to try downloading toolchain from a specific tag
144+
download_toolchain() {
145+
local ref="$1"
146+
local download_url="https://github.com/netsurf-browser/toolchains/releases/download/${ref}/${TOOLCHAIN_NAME}.tar.gz"
147+
148+
echo "Trying to download toolchain from ref: $ref"
149+
echo "URL: $download_url"
150+
151+
if curl -f -L -o "${TOOLCHAIN_NAME}.tar.gz" "$download_url"; then
152+
echo "Got toolchain with ref: $ref"
153+
return 0
154+
else
155+
echo "Failed to download toolchain with ref: $ref"
156+
return 1
157+
fi
158+
}
159+
160+
# Try branch-specific toolchain first
161+
safe_branch=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9._-]/-/g')
162+
branch_tag="gh-${safe_branch}-unstable"
163+
164+
if download_toolchain "$branch_tag"; then
165+
echo "Downloaded branch-specific toolchain"
166+
elif download_toolchain "gh-master-unstable"; then
167+
echo "Downloaded fallback master toolchain"
168+
else
169+
echo "Failed to download any toolchain variant"
170+
exit 1
171+
fi
172+
173+
- name: Install toolchain
174+
run: |
175+
echo "Installing toolchain: ${{ matrix.toolchain }}"
176+
sudo tar -xzf "${{ matrix.toolchain }}.tar.gz" -C /
177+
rm "${{ matrix.toolchain }}.tar.gz"
178+
echo "Toolchain testament:"
179+
cat /opt/netsurf/${{ matrix.toolchain }}/BUILD_INFO.txt
180+
181+
- name: Build and install project libs
182+
env:
183+
HOST: "${{ matrix.toolchain }}"
184+
TARGET_WORKSPACE: "${{ github.workspace }}/projects" # Same as "$(pwd)/projects"
185+
TARGET: ${{ github.event.repository.name }}
186+
Q:
187+
run: |
188+
echo "HOST=$HOST"
189+
echo "TARGET_WORKSPACE=$TARGET_WORKSPACE"
190+
191+
echo "Looking for cross-compiler tools..."
192+
echo "Expected path: /opt/netsurf/${HOST}/cross/bin/"
193+
if [ -f "/opt/netsurf/${HOST}/cross/bin/${HOST}-gcc" ]; then
194+
echo "Found: /opt/netsurf/${HOST}/cross/bin/${HOST}-gcc"
195+
echo "Testing if it's executable:"
196+
/opt/netsurf/${HOST}/cross/bin/${HOST}-gcc --version || echo "Failed to execute gcc --version"
197+
echo "Testing dumpmachine output:"
198+
/opt/netsurf/${HOST}/cross/bin/${HOST}-gcc -dumpmachine || echo "Failed to execute gcc -dumpmachine"
199+
else
200+
echo "NOT FOUND: /opt/netsurf/${HOST}/cross/bin/${HOST}-gcc"
201+
fi
202+
203+
echo "Sourcing env.sh with error checking..."
204+
set -e # Exit on any error
205+
if ! source projects/env.sh; then
206+
echo "env.sh failed with exit code $?"
207+
exit 1
208+
fi
209+
echo "env.sh sourced successfully"
210+
echo "BUILD=$BUILD"
211+
echo "HOST=$HOST"
212+
echo "TARGET_WORKSPACE=$TARGET_WORKSPACE"
213+
echo "USE_CPUS=$USE_CPUS"
214+
215+
echo "Cloning libs..."
216+
ns-clone -d -s -b ${GITHUB_REF_NAME}
217+
echo "Building and installing tools..."
218+
ns-make-tools install
219+
echo "Building and installing libs..."
220+
ns-make-libs install
221+
222+
- name: Build Library
223+
env:
224+
HOST: "${{ matrix.toolchain }}"
225+
TARGET_WORKSPACE: "${{ github.workspace }}/projects" # Same as "$(pwd)/projects"
226+
Q:
227+
run: |
228+
echo "Sourcing env.sh with error checking..."
229+
set -e # Exit on any error
230+
if ! source projects/env.sh; then
231+
echo "env.sh failed with exit code $?"
232+
exit 1
233+
fi
234+
make -j"$(nproc)"
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: "Static Analysis"
2+
3+
on: [push]
4+
5+
jobs:
6+
codeql:
7+
name: codeql
8+
runs-on: ubuntu-22.04
9+
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
language: ['cpp']
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v6
18+
with:
19+
fetch-depth: 1
20+
21+
- name: apt-get install packages
22+
run: sudo apt-get update -qq &&
23+
sudo apt-get install --no-install-recommends -y
24+
bison
25+
build-essential
26+
check
27+
clang
28+
flex
29+
git
30+
gperf
31+
llvm
32+
pkg-config
33+
34+
- name: Get env.sh
35+
run: |
36+
mkdir projects
37+
wget -O projects/env.sh https://raw.githubusercontent.com/netsurf-browser/netsurf/refs/heads/master/docs/env.sh
38+
39+
- name: Build and install project deps
40+
env:
41+
TARGET: ${{ github.event.repository.name }}
42+
run: |
43+
export TARGET_WORKSPACE="$(pwd)/projects"
44+
source projects/env.sh
45+
ns-clone -d -s
46+
ns-make-libs install
47+
48+
- name: Initialize CodeQL
49+
uses: github/codeql-action/init@v4
50+
with:
51+
languages: ${{ matrix.language }}
52+
53+
- name: Build Library
54+
run: |
55+
export TARGET_WORKSPACE="$(pwd)/projects"
56+
source projects/env.sh
57+
make -j"$(nproc)"
58+
59+
- name: Perform CodeQL Analysis
60+
uses: github/codeql-action/analyze@v4

0 commit comments

Comments
 (0)