diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..78916832df --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,129 @@ +name: CI for Express Backend Servers + +on: + push: + branches: + - "*" + pull_request: + branches: + - "*" + +env: + NODE_VERSION: "16" + COLLABORATION_SERVICE_URL: "http://localhost:8001/api" + MATCHING_SERVICE_URL: "http://localhost:8002/api" + QUESTION_SERVICE_URL: "http://localhost:8003/api" + USER_SERVICE_URL: "http://localhost:8004/api" + +jobs: + collaboration_service: + runs-on: ubuntu-latest + name: Collaboration Service + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Install dependencies + working-directory: ./collaboration-service + run: npm install + + - name: Build the service + working-directory: ./collaboration-service + run: npm run build + + - name: Start the service + working-directory: ./collaboration-service + run: | + nohup npm run start & sleep 5 + curl --fail ${{ env.COLLABORATION_SERVICE_URL }} || exit 1 + + - name: Stop the service + run: pkill node + + matching_service: + runs-on: ubuntu-latest + name: Matching Service + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Install dependencies + working-directory: ./matching-service + run: npm install + + - name: Build the service + working-directory: ./matching-service + run: npm run build + + - name: Start the service + working-directory: ./matching-service + run: | + nohup npm run start & sleep 5 + curl --fail ${{ env.MATCHING_SERVICE_URL }} || exit 1 + + - name: Stop the service + run: pkill node + + question_service: + runs-on: ubuntu-latest + name: Question Service + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Install dependencies + working-directory: ./question-service + run: npm install + + - name: Build the service + working-directory: ./question-service + run: npm run build + + - name: Start the service + working-directory: ./question-service + run: | + nohup npm run start & sleep 5 + curl --fail ${{ env.QUESTION_SERVICE_URL }} || exit 1 + + - name: Stop the service + run: pkill node + + user_service: + runs-on: ubuntu-latest + name: User Service + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Install dependencies + working-directory: ./user-service + run: npm install + + - name: Start the service + working-directory: ./user-service + run: | + nohup npm run start & sleep 5 + curl --fail ${{ env.USER_SERVICE_URL }} || exit 1 + + - name: Stop the service + run: pkill node