diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 971c1fe52b..d987c379b0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,196 +13,6 @@ on: workflow_dispatch: jobs: - question-service-tests: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up .env - env: - QUESTION_FIREBASE_CREDENTIAL_PATH: ${{ vars.QUESTION_SERVICE_FIREBASE_CREDENTIAL_PATH }} - JWT_SECRET: ${{ secrets.JWT_SECRET }} - run: | - cd ./apps/question-service - - echo "FIREBASE_CREDENTIAL_PATH=$QUESTION_FIREBASE_CREDENTIAL_PATH" >> .env - echo "JWT_SECRET=$JWT_SECRET" >> .env - - - name: Set up credentials - env: - QUESTION_FIREBASE_JSON: ${{ secrets.QUESTION_SERVICE_FIREBASE_CREDENTIAL }} - QUESTION_FIREBASE_CREDENTIAL_PATH: ${{ vars.QUESTION_SERVICE_FIREBASE_CREDENTIAL_PATH }} - run: | - cd ./apps/question-service - echo "$QUESTION_FIREBASE_JSON" > "./$QUESTION_FIREBASE_CREDENTIAL_PATH" - - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: '1.23.x' - - - name: Install dependencies - run: | - cd ./apps/question-service - go mod tidy - - - name: Run tests - run: | - cd ./apps/question-service - go test ./... - - frontend-unit-tests: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Setup .env - run: | - cd ./apps/frontend - cp .env.example .env - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: '22' - - - name: Install pnpm - run: npm i -g pnpm - - - name: Install dependencies - run: | - cd ./apps/frontend - pnpm i - - - name: Run tests - run: | - cd ./apps/frontend - pnpm test - - test: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Docker Compose - run: | - sudo apt-get update - sudo apt-get install -y docker-compose - - - name: Create Environment Files - env: - QUESTION_SERVICE_URL: ${{ vars.QUESTION_SERVICE_URL }} - USER_SERVICE_URL: ${{ vars.USER_SERVICE_URL }} - MATCHING_SERVICE_URL: ${{ vars.MATCHING_SERVICE_URL }} - HISTORY_SERVICE_URL: ${{ vars.HISTORY_SERVICE_URL }} - SIGNALLING_SERVICE_URL: ${{ vars.SIGNALLING_SERVICE_URL }} - JWT_SECRET: ${{ secrets.JWT_SECRET }} - QUESTION_FIREBASE_CREDENTIAL_PATH: ${{ vars.QUESTION_SERVICE_FIREBASE_CREDENTIAL_PATH }} - HISTORY_FIREBASE_CREDENTIAL_PATH: ${{ vars.HISTORY_SERVICE_FIREBASE_CREDENTIAL_PATH }} - DB_CLOUD_URI: ${{ secrets.USER_SERVICE_DB_CLOUD_URI }} - USER_SERVICE_PORT: ${{ vars.USER_SERVICE_PORT }} - MATCHING_SERVICE_PORT: ${{ vars.MATCHING_SERVICE_PORT }} - HISTORY_SERVICE_PORT: ${{ vars.HISTORY_SERVICE_PORT }} - SIGNALLING_SERVICE_PORT: ${{ vars.SIGNALLING_SERVICE_PORT }} - MATCHING_SERVICE_TIMEOUT: ${{ vars.MATCHING_SERVICE_TIMEOUT }} - REDIS_URL: ${{ vars.REDIS_URL }} - QUESTION_SERVICE_GRPC_URL: ${{ vars.QUESTION_SERVICE_GPRC_URL }} - run: | - cd ./apps/frontend - echo "NEXT_PUBLIC_QUESTION_SERVICE_URL=$QUESTION_SERVICE_URL" >> .env - echo "NEXT_PUBLIC_USER_SERVICE_URL=$USER_SERVICE_URL" >> .env - echo "NEXT_PUBLIC_MATCHING_SERVICE_URL=$MATCHING_SERVICE_URL" >> .env - echo "NEXT_PUBLIC_HISTORY_SERVICE_URL=$HISTORY_SERVICE_URL" >> .env - echo "NEXT_PUBLIC_SIGNALLING_SERVICE_URL=$SIGNALLING_SERVICE_URL" >> .env - - cd ../question-service - echo "FIREBASE_CREDENTIAL_PATH=$QUESTION_FIREBASE_CREDENTIAL_PATH" >> .env - echo "JWT_SECRET=$JWT_SECRET" >> .env - - cd ../user-service - echo "DB_CLOUD_URI=$DB_CLOUD_URI" >> .env - echo "PORT=$USER_SERVICE_PORT" >> .env - echo "JWT_SECRET=$JWT_SECRET" >> .env - - cd ../matching-service - echo "PORT=$MATCHING_SERVICE_PORT" >> .env - echo "MATCH_TIMEOUT=$MATCHING_SERVICE_TIMEOUT" >> .env - echo "JWT_SECRET=$JWT_SECRET" >> .env - echo "REDIS_URL=$REDIS_URL" >> .env - echo "QUESTION_SERVICE_GRPC_URL=$QUESTION_SERVICE_GRPC_URL" >> .env - - cd ../history-service - echo "FIREBASE_CREDENTIAL_PATH=$HISTORY_FIREBASE_CREDENTIAL_PATH" >> .env - echo "PORT=$HISTORY_SERVICE_PORT" >> .env - - cd ../signalling-service - echo "PORT=$SIGNALLING_SERVICE_PORT" >> .env - - - name: Create Database Credential Files - env: - QUESTION_FIREBASE_JSON: ${{ secrets.QUESTION_SERVICE_FIREBASE_CREDENTIAL }} - QUESTION_FIREBASE_CREDENTIAL_PATH: ${{ vars.QUESTION_SERVICE_FIREBASE_CREDENTIAL_PATH }} - HISTORY_FIREBASE_JSON: ${{ secrets.HISTORY_SERVICE_FIREBASE_CREDENTIAL }} - HISTORY_FIREBASE_CREDENTIAL_PATH: ${{ vars.HISTORY_SERVICE_FIREBASE_CREDENTIAL_PATH }} - run: | - cd ./apps/question-service - echo "$QUESTION_FIREBASE_JSON" > "./$QUESTION_FIREBASE_CREDENTIAL_PATH" - - cd ../history-service - echo "$HISTORY_FIREBASE_JSON" > "./$HISTORY_FIREBASE_CREDENTIAL_PATH" - - - name: Build and Run Services - run: | - cd ./apps - docker-compose up --build -d - - - name: Wait for services to be ready - run: sleep 30 - - - name: Install websocat - run: | - sudo wget -qO /usr/local/bin/websocat https://github.com/vi/websocat/releases/latest/download/websocat.x86_64-unknown-linux-musl - sudo chmod a+x /usr/local/bin/websocat - websocat --version - - - name: Run Tests - env: - FRONTEND_URL: ${{ vars.FRONTEND_URL }} - USER_SERVICE_URL: ${{ vars.USER_SERVICE_URL }} - QUESTION_SERVICE_URL: ${{ vars.QUESTION_SERVICE_URL }} - MATCHING_SERVICE_URL: ${{ vars.MATCHING_SERVICE_URL }} - HISTORY_SERVICE_URL: ${{ vars.HISTORY_SERVICE_URL }} - SIGNALLING_SERVICE_URL: ${{ vars.SIGNALLING_SERVICE_URL }} - run: | - echo "Testing Question Service..." - curl -sSL -o /dev/null $QUESTION_SERVICE_URL && echo "Question Service is up" - echo "Testing User Service..." - curl -fsSL -o /dev/null $USER_SERVICE_URL && echo "User Service is up" - echo "Testing Frontend..." - curl -fsSL -o /dev/null $FRONTEND_URL && echo "Frontend is up" - echo "Testing History Service..." - curl -fsSL -o /dev/null $HISTORY_SERVICE_URL && echo "History Service is up" - echo "Testing Matching Service..." - if ! (echo "Hello" | websocat $MATCHING_SERVICE_URL); then - echo "WebSocket for Matching Service is not live" - else - echo "WebSocket for Matching Service is live" - fi - # Add in test for matching service in the future - echo "Testing Signalling Service..." - if ! (echo "Hello" | websocat $SIGNALLING_SERVICE_URL); then - echo "WebSocket for Signalling Service is not live" - else - echo "WebSocket for Signalling Service is live" - fi - # We can add more tests here - test-firebase: runs-on: ubuntu-latest steps: @@ -211,4 +21,4 @@ jobs: with: args: emulators:start --only firestore --project demo-test-project env: - GCP_SA_KEY: "{}" + GCP_SA_KEY: asdf