Merge pull request #11 from ReproNim/feat/github-pages-deployment #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test Generated Project | ||
| on: | ||
| push: | ||
| branches: [main, dev, 'feat/*'] | ||
| pull_request: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
| jobs: | ||
| test-generated-project: | ||
| name: Test generated project functionality | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '18' | ||
| - name: Install cookiecutter | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install cookiecutter | ||
| - name: Generate test project | ||
| run: | | ||
| cookiecutter . --no-input \ | ||
| protocol_name="CI Test Protocol" \ | ||
| protocol_description="Testing in CI/CD" \ | ||
| github_org="repronim" \ | ||
| github_repo="test-protocol" \ | ||
| number_of_activities=3 | ||
| - name: Test generated Makefile | ||
| working-directory: ./CI Test Protocol | ||
| run: | | ||
| # Test help command | ||
| make help | ||
| # Test git-init (should work even if already initialized) | ||
| make git-init || true | ||
| - name: Install reproschema-py for validation | ||
| run: pip install reproschema | ||
| - name: Validate protocol schema | ||
| working-directory: ./CI Test Protocol | ||
| run: | | ||
| # Check that the protocol schema is valid JSON | ||
| python -m json.tool ci_test_protocol/ci_test_protocol_schema > /dev/null | ||
| echo "✓ Protocol schema is valid JSON" | ||
| # Validate structure | ||
| python -c " | ||
| import json | ||
| with open('ci_test_protocol/ci_test_protocol_schema') as f: | ||
| schema = json.load(f) | ||
| # Check required fields | ||
| assert '@context' in schema | ||
| assert '@type' in schema | ||
| assert schema['@type'] == 'reproschema:Protocol' | ||
| assert 'schemaVersion' in schema | ||
| assert schema['schemaVersion'] == '1.0.0' | ||
| assert 'ui' in schema | ||
| assert 'addProperties' in schema['ui'] | ||
| assert 'order' in schema['ui'] | ||
| # Check that we have 3 activities | ||
| assert len(schema['ui']['addProperties']) == 3 | ||
| assert len(schema['ui']['order']) == 3 | ||
| print('✓ Protocol schema structure is correct') | ||
| " | ||
| - name: Check activity schemas | ||
| working-directory: ./CI Test Protocol | ||
| run: | | ||
| python -c " | ||
| import json | ||
| import os | ||
| from pathlib import Path | ||
| activity_count = 0 | ||
| for activity_dir in Path('activities').iterdir(): | ||
| if activity_dir.is_dir(): | ||
| activity_count += 1 | ||
| schema_files = list(activity_dir.glob('*_schema')) | ||
| if not schema_files: | ||
| print(f'✗ No schema found in {activity_dir}') | ||
| exit(1) | ||
| for schema_file in schema_files: | ||
| with open(schema_file) as f: | ||
| schema = json.load(f) | ||
| # Check schema structure | ||
| assert '@context' in schema | ||
| assert '@type' in schema | ||
| assert schema['@type'] == 'reproschema:Activity' | ||
| assert 'schemaVersion' in schema | ||
| assert schema['schemaVersion'] == '1.0.0' | ||
| print(f'✓ {schema_file} is valid') | ||
| print(f'\n✓ Found and validated {activity_count} activities') | ||
| assert activity_count == 3, f'Expected 3 activities but found {activity_count}' | ||
| " | ||
| - name: Test reproschema-ui configuration | ||
| working-directory: ./CI Test Protocol | ||
| run: | | ||
| # Check config.env exists and has checksum | ||
| test -f config.env | ||
| grep -q "REPROSCHEMA_UI_CHECKSUM=" config.env | ||
| echo "✓ UI configuration is set up" | ||
| # Check ui-changes directory | ||
| test -d ui-changes | ||
| test -f ui-changes/src/config.js | ||
| echo "✓ UI customization directory exists" | ||
| - name: Check no hardcoded activities remain | ||
| working-directory: ./CI Test Protocol | ||
| run: | | ||
| # Ensure Activity4 is not referenced anywhere | ||
| if grep -r "Activity4" --include="*_schema" .; then | ||
| echo "✗ ERROR: Found Activity4 references" | ||
| exit 1 | ||
| fi | ||
| echo "✓ No invalid activity references found" | ||
| - name: Test schema version consistency | ||
| working-directory: ./CI Test Protocol | ||
| run: | | ||
| python -c " | ||
| from pathlib import Path | ||
| import re | ||
| version_pattern = re.compile(r'reproschema/([^/]+)/contexts') | ||
| versions = set() | ||
| for schema_file in Path('.').rglob('*_schema'): | ||
| with open(schema_file) as f: | ||
| content = f.read() | ||
| matches = version_pattern.findall(content) | ||
| versions.update(matches) | ||
| print(f'Found schema versions: {versions}') | ||
| if len(versions) > 1: | ||
| print('✗ ERROR: Multiple schema versions found') | ||
| exit(1) | ||
| if '1.0.0' not in versions: | ||
| print('✗ ERROR: Not using stable 1.0.0 version') | ||
| exit(1) | ||
| print('✓ All schemas use consistent version 1.0.0') | ||
| " | ||