Update README.md #14
Workflow file for this run
This file contains 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
# Trigger the workflow on pull requests targeting the main branch | |
on: | |
pull_request: | |
branches: [ "main", "Analytics" ] | |
jobs: | |
# Define the job for backend testing | |
backend-test: | |
# Specify the runner to use for the job | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 # Check out the repository content | |
# Set up JDK 17 for the job using the setup-java action | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
# Compile the backend application using Maven | |
- name: Building backend using Maven | |
run: mvn clean install | |
working-directory: backend | |
# Run the backend tests using Maven | |
- name: Running backend test using Maven | |
run: mvn test | |
working-directory: backend | |
# Define the job for frontend testing | |
frontend-test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.x] | |
steps: | |
- uses: actions/checkout@v3 # Check out the repository content | |
# Set up the specified Node.js version for the job | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
# Install NPM dependencies | |
- name: Installing frontend packages using NPM | |
run: npm ci | |
working-directory: frontend | |
# Build the frontend application | |
- name: Building frontend using NPM | |
run: npm run build --if-present | |
working-directory: frontend | |
# Run the frontend tests | |
- name: Running frontend test using NPM | |
run: npm test | |
working-directory: frontend | |
# Define the job for running Selenium tests | |
selenium-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 # Check out the repository content | |
# Start services and run Selenium tests | |
- name: Start services and run tests | |
id: test | |
run: | | |
#!/bin/bash | |
# Start the test process in the background and capture its output | |
docker-compose -f docker-compose-dev.yml up --build | tee logs.txt & | |
PID=$! | |
# Monitor the log file for a message indicating that tests are complete | |
(tail -f -n0 logs.txt &) | grep -q "Ports 8080 and 3000 have been successfully released" | |
# If the test process is still running, kill it to allow the workflow to proceed | |
if kill -0 $PID 2>/dev/null; then | |
echo "Tests completed. Stopping the test process." | |
kill $PID | |
fi | |
continue-on-error: true | |
# Cleanup services after tests have run | |
- name: Cleanup services | |
if: always() | |
run: docker-compose -f docker-compose-dev.yml down | |
# Analyze the test results to determine if the job should pass or fail | |
- name: Analyze test results | |
id: analyze | |
run: | | |
# Check the logs for the test outcome | |
if grep -q 'Tests:.*28 passed' logs.txt; then | |
echo "tests_passed=true" >> $GITHUB_ENV | |
else | |
echo "tests_passed=false" >> $GITHUB_ENV | |
fi | |
# Conditionally fail the job if the test analysis found failures | |
- name: Fail the job if tests failed | |
if: env.tests_passed == 'false' | |
run: exit 1 |