Skip to content
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
167 changes: 167 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# This workflow runs continuous integration tests on pull requests and pushes
#
# It validates code quality, runs tests, and ensures the application builds correctly
# before changes are merged into the main branches.

name: 'Continuous Integration'

on:
push:
branches:
- develop
- master
- main
pull_request:
branches:
- develop
- master
- main
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
php-lint:
name: PHP Syntax Check
runs-on: ubuntu-latest

strategy:
matrix:
php-version: ['7.4', '8.0', '8.1', '8.2']

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, xml, ctype, json, mysql
coverage: none

- name: Validate composer.json
run: |
if [ -f "openml_OS/composer.json" ]; then
cd openml_OS
composer validate --strict
fi

- name: Install Composer Dependencies
run: |
if [ -f "openml_OS/composer.json" ]; then
cd openml_OS
composer install --no-interaction --prefer-dist --no-progress
fi

- name: PHP Syntax Check
run: |
find . -name "*.php" -not -path "./vendor/*" -not -path "./node_modules/*" -print0 | xargs -0 -n1 php -l

javascript-lint:
name: JavaScript Syntax Check
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: '**/package-lock.json'

- name: Install Dependencies
if: hashFiles('**/package.json') != ''
run: npm ci || npm install

- name: JavaScript Lint
if: hashFiles('**/package.json') != ''
run: |
# Check if eslint is available
if command -v eslint &> /dev/null; then
npm run lint || echo "No lint script found"
else
echo "ESLint not configured, skipping"
fi

docker-build:
name: Docker Build Test
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker Image
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
push: false
tags: openml/php-rest-api:test
cache-from: type=gha
cache-to: type=gha,mode=max

code-quality:
name: Code Quality Analysis
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: none

- name: Install Dependencies
run: |
if [ -f "openml_OS/composer.json" ]; then
cd openml_OS
composer install --no-interaction --prefer-dist
fi

- name: Check Code Style
continue-on-error: true
run: |
echo "Code style check would run here"
# Add your code style checker (e.g., PHP_CodeSniffer, PHP-CS-Fixer)

test-summary:
name: Test Summary
runs-on: ubuntu-latest
needs: [php-lint, javascript-lint, docker-build, code-quality]
if: always()

steps:
- name: Test Status Summary
run: |
echo "### CI Test Results 📊" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Job | Status |" >> $GITHUB_STEP_SUMMARY
echo "|-----|--------|" >> $GITHUB_STEP_SUMMARY
echo "| PHP Lint | ${{ needs.php-lint.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| JavaScript Lint | ${{ needs.javascript-lint.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| Docker Build | ${{ needs.docker-build.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| Code Quality | ${{ needs.code-quality.result }} |" >> $GITHUB_STEP_SUMMARY

- name: Check if All Tests Passed
if: |
needs.php-lint.result != 'success' ||
needs.javascript-lint.result != 'success' ||
needs.docker-build.result != 'success'
run: |
echo "❌ Some tests failed. Please check the logs above."
exit 1