ci [N/A] #563
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: ci | |
| run-name: ci [${{ inputs.uuid || 'N/A' }}] | |
| on: | |
| push: | |
| workflow_dispatch: | |
| inputs: | |
| uuid: | |
| description: 'Unique ID' | |
| required: false | |
| jobs: | |
| lint: | |
| name: Lint Python and JavaScript | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install Python lint dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install flake8 | |
| - name: Run flake8 | |
| run: flake8 api/ db/ | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install Prettier | |
| run: npm install --no-save prettier | |
| - name: Run Prettier | |
| run: npx prettier --check app/src/app | |
| apache_deployment: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Define global variables | |
| id: global_variables | |
| run: | | |
| echo "BRANCH_NAME=${{ github.head_ref || github.ref_name }}" >> "$GITHUB_OUTPUT" | |
| sed -i 's/^BASIL_TESTING=.*/BASIL_TESTING=1/' deploy/apache/.env | |
| sed -i 's/^BASIL_API_PORT=.*/BASIL_API_PORT=5005/' deploy/apache/.env | |
| sed -i 's/^BASIL_APP_PORT=.*/BASIL_APP_PORT=9056/' deploy/apache/.env | |
| sed -i 's/^BASIL_ADMIN_PASSWORD=.*/BASIL_ADMIN_PASSWORD=dummy_password/' deploy/apache/.env | |
| sed -i 's/^BASIL_DB_PASSWORD=.*/BASIL_DB_PASSWORD=dbSecret123/' deploy/apache/.env | |
| TEMPDIR=$(mktemp -d) | |
| sed -i "s|^BASIL_DB_PASSWORD=.*|BASIL_DB_PASSWORD=${TEMPDIR}|" deploy/apache/.env | |
| - name: Make deploy/apache/run.sh executable | |
| run: chmod +x deploy/apache/run.sh | |
| - name: Run the deployment | |
| run: | | |
| cd deploy/apache && sudo ./run.sh | |
| - name: Test backend and frontend are up | |
| run: | | |
| echo "Test Api is running" | |
| curl -vf http://localhost:5005/apis | |
| curl -vf http://localhost:5005/libraries | |
| curl -vf http://localhost:5005/version | |
| echo "Test App is running" | |
| curl -vf http://localhost:9056 | |
| - name: Install cypress-fail-fast plugin | |
| run: npm install --save-dev cypress-fail-fast | |
| working-directory: ./app | |
| - name: Cypress E2E Testing Chrome | |
| uses: cypress-io/github-action@v6 | |
| with: | |
| browser: chrome | |
| working-directory: ./app | |
| spec: 'cypress/**/*.cy.js' | |
| command: npx cypress run --browser chrome --spec cypress/**/login.cy.js --env failFast=true | |
| env: | |
| LIBGL_ALWAYS_SOFTWARE: 1 | |
| - name: Upload Cypress screenshots | |
| uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: cypress-screenshots | |
| path: | | |
| app/cypress/screenshots | |
| api/user-files | |
| retention-days: 7 | |
| - name: Upload apache error log | |
| uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: apache-error.log | |
| path: /var/log/apache2/error.log | |
| build_and_test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| # TEST_RUNS_BASE_DIR required by pytest | |
| - name: Define global variables | |
| id: global_variables | |
| run: | | |
| echo "BRANCH_NAME=${{ github.head_ref || github.ref_name }}" >> "$GITHUB_OUTPUT" | |
| echo "BASIL_ADMIN_PASSWORD=dummy_password" >> "$GITHUB_ENV" | |
| echo "BASIL_API_PORT=5005" >> "$GITHUB_ENV" | |
| echo "BASIL_APP_PORT=9056" >> "$GITHUB_ENV" | |
| echo "BASIL_DB_PASSWORD=dbSecret123" >> "$GITHUB_ENV" | |
| echo "BASIL_DB_PORT=5432" >> "$GITHUB_ENV" | |
| echo "BASIL_TESTING=1" >> "$GITHUB_ENV" | |
| TEMPDIR=$(mktemp -d) | |
| echo "TEST_RUNS_BASE_DIR=$TEMPDIR" >> $GITHUB_ENV | |
| - name: Install Podman (if needed) | |
| run: | | |
| sudo apt update | |
| sudo apt install -y podman | |
| - name: Install PostgreSQL client tools | |
| run: sudo apt-get update && sudo apt-get install -y postgresql-client | |
| - name: Make run_demo.sh executable | |
| run: chmod +x ./run_demo.sh | |
| - name: Run demo environment | |
| run: | | |
| sudo ./run_demo.sh \ | |
| -b $BASIL_API_PORT \ | |
| -f $BASIL_APP_PORT \ | |
| -p $BASIL_ADMIN_PASSWORD \ | |
| -t $BASIL_TESTING \ | |
| -u 'http://localhost' \ | |
| -w $BASIL_DB_PASSWORD | |
| - name: Install wait-on | |
| run: npm install -g wait-on | |
| - name: Wait for PostgreSQL to be ready | |
| run: | | |
| for i in {1..10}; do | |
| if pg_isready -h localhost -p $BASIL_DB_PORT; then | |
| echo "PostgreSQL is ready" | |
| break | |
| fi | |
| echo "Waiting for PostgreSQL..." | |
| sleep 3 | |
| done | |
| - name: Wait for API to be ready | |
| run: wait-on http://localhost:$BASIL_API_PORT/apis --timeout 120000 | |
| - name: Wait for frontend to be ready (optional) | |
| run: wait-on http://localhost:$BASIL_APP_PORT --timeout 120000 | |
| - name: Test Container are up and running | |
| run: | | |
| echo "Test Api is running" | |
| curl -vf http://localhost:$BASIL_API_PORT/apis | |
| curl -vf http://localhost:$BASIL_API_PORT/libraries | |
| curl -vf http://localhost:$BASIL_API_PORT/version | |
| echo "Test App is running" | |
| curl -vf http://localhost:$BASIL_APP_PORT | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install python dependencies | |
| run: | | |
| pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: API unit testing | |
| run: | | |
| pytest -v ./api/test --cov=api --cov-branch --cov-report=term --cov-report=html | |
| - name: Create tarball of coverage report | |
| run: | | |
| tar -czf api-htmlcov.tar.gz htmlcov | |
| - name: Upload coverage report artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: api-coverage-html-report | |
| path: api-htmlcov.tar.gz | |
| - name: Init clean db after API Testing | |
| run: | | |
| curl -vf http://localhost:$BASIL_API_PORT/test-support/init-db | |
| sleep 10 | |
| echo "Test Api is running" | |
| curl -vf http://localhost:$BASIL_API_PORT/apis | |
| curl -vf http://localhost:$BASIL_API_PORT/libraries | |
| curl -vf http://localhost:$BASIL_API_PORT/version | |
| - name: Install cypress-fail-fast plugin | |
| run: npm install --save-dev cypress-fail-fast | |
| working-directory: ./app | |
| - name: Cypress E2E Testing Chrome | |
| uses: cypress-io/github-action@v6 | |
| with: | |
| browser: chrome | |
| working-directory: ./app | |
| spec: 'cypress/**/*.cy.js' | |
| command: npx cypress run --browser chrome --spec cypress/**/*.cy.js --env failFast=true | |
| env: | |
| LIBGL_ALWAYS_SOFTWARE: 1 | |
| - name: Upload Cypress screenshots | |
| uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: cypress-screenshots | |
| path: | | |
| app/cypress/screenshots | |
| api/user-files | |
| retention-days: 7 | |
| - name: Collect logs of all running Podman containers | |
| if: always() | |
| run: | | |
| mkdir -p podman-logs | |
| for cid in $(sudo podman ps -a -q); do | |
| cname=$(sudo podman inspect --format '{{.Name}}' "$cid" | sed 's/^\///') | |
| { | |
| echo "=== Container: $cname ===" | |
| sudo podman inspect --format 'Status: {{.State.Status}}, ExitCode: {{.State.ExitCode}}' "$cid" | |
| echo | |
| sudo podman logs "$cid" | |
| } > "podman-logs/${cname}.log" | |
| done | |
| ls -lh podman-logs | |
| - name: Copy /var/tmp/tmt from basil-api-latest container | |
| if: failure() | |
| run: | | |
| sudo podman cp basil-api-latest:/var/test-runs ./tmt-logs | |
| tar -czf tmt-logs.tar.gz ./tmt-logs | |
| - name: Upload tmt logs as artifact | |
| uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: tmt-logs | |
| path: tmt-logs.tar.gz | |
| - name: Upload Podman logs | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: podman-logs | |
| path: podman-logs/ |