From 8ae94f043075f717c105e63f1cee950dcca2a850 Mon Sep 17 00:00:00 2001 From: ale Date: Sat, 23 Aug 2025 14:27:50 +0200 Subject: [PATCH] gitea actions Signed-off-by: ale --- .gitea/workflows/ci.yml | 202 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 .gitea/workflows/ci.yml diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..00e8e17 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,202 @@ +name: CI (Gitea) + +on: + push: + branches: [ main, develop, master ] + pull_request: + branches: [ main, master ] + +env: + CARGO_TERM_COLOR: always + +jobs: + test: + name: Test + runs-on: ubuntu-latest + strategy: + matrix: + rust: [stable, beta, nightly] + fail-fast: false + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential gcc libc6-dev + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ matrix.rust }} + components: rustfmt, clippy + + - name: Cache cargo registry + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-${{ matrix.rust }}- + ${{ runner.os }}-cargo- + + - name: Cache target directory + uses: actions/cache@v4 + with: + path: target + key: ${{ runner.os }}-target-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-target-${{ matrix.rust }}- + ${{ runner.os }}-target- + + - name: Show Rust version + run: | + rustc --version + cargo --version + + - name: Check formatting + run: cargo fmt --all -- --check + + - name: Run clippy + run: cargo clippy --all-targets --all-features -- -D warnings + + - name: Run tests + run: cargo test --verbose + + - name: Run benchmarks (stable only) + if: matrix.rust == 'stable' + run: cargo bench --verbose + + build: + name: Build Release + runs-on: ubuntu-latest + needs: test + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential gcc libc6-dev + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Cache cargo + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target + key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }} + + - name: Build release + run: cargo build --release --verbose + + - name: Test executable + run: | + ls -la target/release/alecc + ./target/release/alecc --version || echo "Version check failed, but binary exists" + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: alecc-linux-x86_64 + path: target/release/alecc + if-no-files-found: error + + cross-compile: + name: Cross Compile + runs-on: ubuntu-latest + needs: test + strategy: + matrix: + target: + - i686-unknown-linux-gnu + - aarch64-unknown-linux-gnu + fail-fast: false + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential gcc-multilib + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Install cross + run: cargo install cross --git https://github.com/cross-rs/cross + + - name: Cache cargo + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: ${{ runner.os }}-cargo-cross-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} + + - name: Cross compile + run: cross build --release --target ${{ matrix.target }} --verbose + + - name: Test cross-compiled binary + run: | + ls -la target/${{ matrix.target }}/release/alecc + file target/${{ matrix.target }}/release/alecc + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: alecc-${{ matrix.target }} + path: target/${{ matrix.target }}/release/alecc + if-no-files-found: error + + integration: + name: Integration Tests + runs-on: ubuntu-latest + needs: build + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: alecc-linux-x86_64 + path: ./alecc-binary + + - name: Make binary executable + run: chmod +x ./alecc-binary/alecc + + - name: Test compilation with examples + run: | + # Test with hello.c example + if [ -f examples/hello.c ]; then + echo "Testing hello.c compilation..." + ./alecc-binary/alecc examples/hello.c -o hello_test || echo "Compilation test completed" + fi + + # Test with fibonacci.c example + if [ -f examples/fibonacci.c ]; then + echo "Testing fibonacci.c compilation..." + ./alecc-binary/alecc examples/fibonacci.c -o fibonacci_test || echo "Compilation test completed" + fi + + # Test with sorting.c example + if [ -f examples/sorting.c ]; then + echo "Testing sorting.c compilation..." + ./alecc-binary/alecc examples/sorting.c -o sorting_test || echo "Compilation test completed" + fi