Skip to content

Sample CI

Sample CI #375

Workflow file for this run

name: Sample CI
on: [ push, pull_request ]
permissions:
contents: read
jobs:
test-functions:
strategy:
matrix:
function:
- hello
- host-details
- log-event
- servicenow
- host-info
- user-management
name: Test ${{ matrix.function }}
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
with:
egress-policy: audit
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
- name: Setup Python
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: '3.13'
cache: 'pip'
cache-dependency-path: 'functions/${{ matrix.function }}/requirements.txt'
- name: Install Python dependencies
run: pip install -r requirements.txt
working-directory: functions/${{ matrix.function }}
- name: Run tests if test_main.py exists
run: |
if [ -f "test_main.py" ]; then
echo "Running tests with test_main.py"
pytest
else
echo "No test_main.py found, skipping tests"
fi
working-directory: functions/${{ matrix.function }}
- name: Verify function starts
run: |
timeout 30s bash -c '
python main.py > output.log 2>&1 &
PID=$!
while ! grep -q "running at port 8081" output.log 2>/dev/null; do
sleep 1
done
echo "✅ Application started successfully"
kill $PID 2>/dev/null || true
' || {
echo "❌ Application failed to start"
cat output.log 2>/dev/null || echo "No output log found"
exit 1
}
working-directory: functions/${{ matrix.function }}
build-ui:
name: Build UI
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
with:
egress-policy: audit
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
- name: Setup Node
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version: 22
cache: 'npm'
cache-dependency-path: 'ui/extensions/hello/package-lock.json'
- name: Install dependencies
run: npm ci
working-directory: ui/extensions/hello
- name: Build React app
run: npm run build
working-directory: ui/extensions/hello
- name: Test React app
run: npm test
working-directory: ui/extensions/hello