Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup CI action to automate testing #103

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
76 changes: 76 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Github Actions

on: [push, pull_request]

jobs:
host-x86-build:
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [gcc, clang]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install prerequisite
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: file build-essential clang
version: 1.0
- name: Build stage 1 artifact
env:
CC: ${{ matrix.compiler }}
run: |
make clean
make slimcc
shell: bash
- name: Test stage 1
run: |
make test || exit 1
shell: bash
- name: Build stage 2 artifact
run: |
make stage2/slimcc
shell: bash
- name: Test stage 2
run: |
make test-stage2 || exit 1
shell: bash
- run: mv slimcc slimcc-${{ matrix.compiler }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: slimcc-${{ matrix.compiler }}
path: slimcc-${{ matrix.compiler }}

test-building-real-world-projects:
needs: host-x86-build
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [gcc, clang]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: slimcc-${{ matrix.compiler }}
- run: |
chmod +x slimcc-${{ matrix.compiler }}
- uses: lukka/get-cmake@latest
with:
useLocalCache: true
- name: Install prerequisite
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: file build-essential clang libssh2-1
version: 1.0
- name: Test Building curl 8.9.1
run: |
git clone --depth 1 https://github.com/curl/curl --branch curl-8_9_1
mkdir curl/cmakebuild
cd curl/cmakebuild
cmake ../ -DCMAKE_C_COMPILER=${GITHUB_WORKSPACE}/slimcc-${{ matrix.compiler }} -DCMAKE_C_FLAGS=-fPIC
make -j
make test-quiet -j
shell: bash