CI: Add arch cross-compile and test (#1)

This commit is contained in:
Vaxry 2023-12-29 17:52:44 +01:00 committed by GitHub
parent 97bf10facd
commit d6bb511810
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 75 additions and 1 deletions

71
.github/workflows/arch.yml vendored Normal file
View file

@ -0,0 +1,71 @@
name: Build & Test (Arch)
on: [push, pull_request, workflow_dispatch]
jobs:
gcc:
name: "gcc build / clang test"
runs-on: ubuntu-latest
container:
image: archlinux
steps:
- name: Checkout repository actions
uses: actions/checkout@v4
with:
sparse-checkout: .github/actions
- name: Get required pkgs
run: |
sed -i 's/SigLevel = Required DatabaseOptional/SigLevel = Optional TrustAll/' /etc/pacman.conf
pacman --noconfirm --noprogressbar -Syyu
pacman --noconfirm --noprogressbar -Sy gcc base-devel cmake clang
- name: Build with gcc
run: |
CC="/usr/bin/gcc" CXX="/usr/bin/g++" cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B ./build
CC="/usr/bin/gcc" CXX="/usr/bin/g++" cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
cp ./build/libhyprlang.so /usr/lib
- name: Build with clang
run: |
rm -rf ./build
CC="/usr/bin/clang" CXX="/usr/bin/clang++" cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B ./build
CC="/usr/bin/clang" CXX="/usr/bin/clang++" cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
rm ./build/libhyprlang.so
- name: Run tests
run: |
cd ./tests && ../build/hyprlang_test
clang:
name: "clang build / gcc test"
runs-on: ubuntu-latest
container:
image: archlinux
steps:
- name: Checkout repository actions
uses: actions/checkout@v4
with:
sparse-checkout: .github/actions
- name: Get required pkgs
run: |
sed -i 's/SigLevel = Required DatabaseOptional/SigLevel = Optional TrustAll/' /etc/pacman.conf
pacman --noconfirm --noprogressbar -Syyu
pacman --noconfirm --noprogressbar -Sy gcc base-devel cmake clang
- name: Build with clang
run: |
CC="/usr/bin/clang" CXX="/usr/bin/clang++" cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B ./build
CC="/usr/bin/clang" CXX="/usr/bin/clang++" cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
cp ./build/libhyprlang.so /usr/lib
- name: Build with gcc
run: |
rm -rf ./build
CC="/usr/bin/gcc" CXX="/usr/bin/g++" cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B ./build
CC="/usr/bin/gcc" CXX="/usr/bin/g++" cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
rm ./build/libhyprlang.so
- name: Run tests
run: |
cd ./tests && ../build/hyprlang_test

View file

@ -39,7 +39,7 @@ CConfig::CConfig(const char* path) {
impl->envVariables.clear();
for (char** env = environ; *env; ++env) {
const std::string ENVVAR = *env;
const std::string ENVVAR = *env ? *env : "";
const auto VARIABLE = ENVVAR.substr(0, ENVVAR.find_first_of('='));
const auto VALUE = ENVVAR.substr(ENVVAR.find_first_of('=') + 1);
impl->envVariables.push_back({VARIABLE, VALUE});

View file

@ -52,6 +52,9 @@ int main(int argc, char** argv, char** envp) {
int ret = 0;
try {
if (!getenv("SHELL"))
setenv("SHELL", "/bin/sh", true);
std::cout << "Starting test\n";
Hyprlang::CConfig config("./config/config.conf");