diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 2c46f6a..2576221 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -11,183 +11,41 @@ jobs: ## Build Back ## - Build_Back: - runs-on: ubuntu-latest - timeout-minutes: 10 - defaults: - run: - working-directory: ./back - environment: Staging - - steps: - - uses: actions/checkout@v3 - - - name: Build Docker - run: docker build -t testback . + Test_Build_Back: + uses: ./.github/workflows/build_back.yml ## Build App ## - Build_Front: - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./front - environment: Staging + Test_Build_App: + uses: ./.github/workflows/build_app.yml + secrets: inherit - steps: - - uses: actions/checkout@v3 +## Build Docker ## - - name: Install Yarn - run: npm install -g yarn - - - name: Install dependencies - run: yarn install - - - name: 🏗 Setup Expo - uses: expo/expo-github-action@v7 - with: - expo-version: latest - eas-version: 3.3.1 - token: ${{ secrets.EXPO_TOKEN }} - - - name: Build Android APK - run: | - eas build -p android --profile debug --local --non-interactive - mv *.apk chromacase.apk - - - name: Upload Artifact - if: github.ref == 'refs/heads/main' - uses: actions/upload-artifact@v3 - with: - name: chromacase.apk - path: front/ + Test_Build_Docker: + needs: [ Test_Build_Back, Test_Build_App ] + uses: ./.github/workflows/build_docker.yml ## Test Backend ## Test_Back: - runs-on: ubuntu-latest - timeout-minutes: 15 - needs: [ Build_Back ] - environment: Staging - - steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - fetch-depth: 0 - - - name: Copy env file to github secret env file - run: | - touch .env - echo "POSTGRES_USER=user" >> .env - echo "POSTGRES_PASSWORD=eip" >> .env - echo "POSTGRES_NAME=chromacase" >> .env - echo "POSTGRES_HOST=db" >> .env - echo "DATABASE_URL=postgresql://user:eip@db:5432/chromacase" >> .env - echo "JWT_SECRET=wow" >> .env - echo "POSTGRES_DB=chromacase" >> .env - echo "API_URL=http://localhost:80/api" >> .env - - - name: Start the service - run: docker-compose up -d back db - - - name: Perform healthchecks - run: | - docker-compose ps -a - wget --retry-connrefused http://localhost:3000 # /healthcheck - - - name: Run robot tests - run: | - pip install -r back/test/robot/requirements.txt - robot -d out back/test/robot/ - - uses: actions/upload-artifact@v3 - if: always() - with: - name: results - path: out - - - name: Write results to Pull Request and Summarry - if: always() && github.event_name == 'pull_request' - uses: joonvena/robotframework-reporter-action@v2.1 - with: - report_path: out/ - gh_access_token: ${{ secrets.GITHUB_TOKEN }} - only_summary: false - - - name: Write results to Summarry - if: always() && github.event_name != 'pull_request' - uses: joonvena/robotframework-reporter-action@v2.1 - with: - report_path: out/ - gh_access_token: ${{ secrets.GITHUB_TOKEN }} - only_summary: true - - - name: Remove .env && stop the service - run: docker-compose down && rm .env + needs: [ Test_Build_Back, Test_Build_App ] + uses: ./.github/workflows/test_back.yml + secrets: inherit ## Test App ## + Test_App: + needs: [ Test_Build_Back, Test_Build_App ] + uses: ./.github/workflows/chromatic.yml + secrets: inherit + ## Deployement ## - Deployement_Docker: - runs-on: ubuntu-latest + Deployement: if: github.ref == 'refs/heads/main' - needs: [ Test_Back ] - environment: Production + needs: [ Test_Build_Docker, Test_Back, Test_App ] + uses: ./.github/workflows/deployment_docker.yml + secrets: inherit - steps: - - uses: actions/checkout@v2 - - - name: Docker meta back - id: meta - uses: docker/metadata-action@v4 - with: - images: ghcr.io/${{github.repository_owner}}/back - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to ghcr - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{github.repository_owner}} - password: ${{secrets.GITHUB_TOKEN}} - - - name: Build and push - uses: docker/build-push-action@v3 - with: - context: ./back - push: true - tags: ${{steps.meta.outputs.tags}} - - name: Docker meta front - id: meta_front - uses: docker/metadata-action@v4 - with: - images: ghcr.io/${{github.repository_owner}}/front - - - name: Build and push front - uses: docker/build-push-action@v3 - with: - context: ./front - push: true - tags: ${{steps.meta_front.outputs.tags}} - build-args: | - API_URL=${{secrets.API_URL}} - SCORO_URL=${{secrets.SCORO_URL}} - - name: Docker meta scorometer - id: meta_scorometer - uses: docker/metadata-action@v4 - with: - images: ghcr.io/${{github.repository_owner}}/scorometer - - - name: Build and push scorometer - uses: docker/build-push-action@v3 - with: - context: ./scorometer - push: true - tags: ${{steps.meta_scorometer.outputs.tags}}