Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Tests

on:
push:
branches:
- main
pull_request:

jobs:
native:
strategy:
matrix:
os: [ubuntu-latest, macos-latest] # TODO: Add windows-latest when officially supported
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4

# Set up Python 3.10 or later
- name: Set up Python 3.10 (Windows)
if: matrix.os == 'windows-latest'
uses: actions/setup-python@v2
with:
python-version: '3.10'

# Install C++ Compiler & Build Tools
- name: Set up C++ environment (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y g++ make cmake
g++ --version
cmake --version
make --version

- name: Set up C++ environment (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install make cmake
echo 'export PATH="/usr/local/opt/gcc/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
g++ --version
cmake --version
make --version

- name: Set up C++ environment (Windows)
if: matrix.os == 'windows-latest'
run: |
choco install mingw --version=8.1.0-1
choco install make cmake
echo C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo C:\ProgramData\chocolatey\lib\cmake\bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
g++ --version
cmake --version
make --version

# Install Qt6
- name: Install Qt6 (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get install -y qt6-base-dev
echo 'export PATH="/usr/lib/qt6/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

- name: Install Qt6 (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install qt6
echo 'export PATH="/opt/homebrew/opt/qt6/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

- name: Install Qt6 (Windows)
if: matrix.os == 'windows-latest'
run: |
python -m pip install aqtinstall
python -m aqt install-qt windows desktop 6.6.0 win64_mingw --outputdir C:\Qt
echo C:\Qt\6.6.0\mingw_64\bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

# Build the Project
- name: Build project
run: make build

- name: Run Unit Tests
run: make test

docker:
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Run Docker Test
run: |
chmod +x ./run_docker.sh
./run_docker.sh
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM ubuntu:24.04 AS builder
WORKDIR /

# Add dependencies
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
git \
ca-certificates \
g++ \
cmake \
make \
mesa-common-dev \
qt6-base-dev \
x11-utils \
x11-xserver-utils \
xvfb
RUN rm -rf /var/lib/apt/lists/*

# Copy CodeAstra into the container
COPY . /CodeAstra
WORKDIR /CodeAstra

# Run dockerized tests script
RUN chmod +x ./test_with_xvbf.sh

CMD ["./test_with_xvbf.sh"]
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PROJECT = CodeAstra
BUILD_DIR = build
BUILD_DIR = $(PWD)/build
EXECUTABLE = $(PROJECT)

# Set CMake options
Expand Down Expand Up @@ -45,7 +45,7 @@ uninstall: clean
fi

# Install the project
install:
install: build
@echo "Installing $(PROJECT)..."
@cd $(BUILD_DIR) && make
@echo "Do you want to create a shortcut on the desktop? (Y/n)"
Expand Down Expand Up @@ -76,7 +76,10 @@ install:
fi
@echo "$(PROJECT) installed."

test:
build_tests: build
@cd $(BUILD_DIR)/tests/ && make

test: build_tests
@for test in ./build/tests/test_*; do \
if [ -f $$test ]; then \
echo "Running $$test..."; \
Expand Down
5 changes: 5 additions & 0 deletions run_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

docker build -t "code-astra:tester" .
docker run --name "code-astra-tester" "code-astra:tester"
docker rm "code-astra-tester"
8 changes: 8 additions & 0 deletions test_with_xvbf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash -e

# Start Xvfb server
Xvfb :99 -screen 0 1024x768x24 &
export DISPLAY=:99

# Run tests
make test
Loading