name: 'Gear Idea: e2e test' on: pull_request: types: [synchronize, labeled, opened, reopened, ready_for_review] branches: [main] paths: - idea/api-gateway/** - idea/common/** - idea/indexer/** - idea/frontend/** - idea/test-balance/** - idea/tests/** - idea/meta-storage/** workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_REGION: ${{ secrets.AWS_REGION }} KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }} KUBE_NAMESPACE: test-env DOCKER_BUILDKIT: 1 REACT_APP_NODE_ADDRESS: ${{ secrets.REACT_APP_NODE_ADDRESS }} REACT_APP_API_URL: ${{ secrets.REACT_APP_API_URL }} REACT_APP_WASM_COMPILER_URL: ${{ secrets.REACT_APP_WASM_COMPILER_URL }} REACT_APP_DEFAULT_NODES_URL: ${{ secrets.REACT_APP_DEFAULT_NODES_URL }} REACT_APP_RRT: '' REACT_APP_HCAPTCHA_SITE_KEY: ${{ secrets.REACT_APP_HCAPTCHA_SITE_KEY }} BINARYEN_VERSION: version_111 jobs: check-labels: if: contains(github.event.pull_request.labels.*.name, 'A2-mergeoncegreen') runs-on: ubuntu-latest steps: - run: echo "Condition passed" build-frontend-pkg: runs-on: ubuntu-latest needs: [check-labels] environment: staging # Declare outputs for next steps outputs: frontend_changed: ${{ steps.check_file_changed.outputs.frontend_changed }} steps: - uses: actions/checkout@v2 with: # Checkout as many commits as needed for the diff fetch-depth: 2 - shell: pwsh id: check_file_changed run: | # Diff HEAD with the previous commit $diff = git diff --name-only HEAD^ HEAD # Check if a file under frontend/ has changed (added, modified, deleted) $SourceDiffFrontend = $diff | Where-Object { $_ -match '^idea/frontend/' } $HasDiffFrontend = $SourceDiffFrontend.Length -gt 0 # Set the output Write-Host "::set-output name=frontend_changed::$HasDiffFrontend" - name: Cancel previous workflow runs if: steps.check_file_changed.outputs.frontend_changed == 'True' uses: styfle/cancel-workflow-action@0.4.0 with: access_token: ${{ github.token }} - if: steps.check_file_changed.outputs.frontend_changed == 'True' uses: c-hive/gha-yarn-cache@v2.1.0 - name: Setup NodeJS if: steps.check_file_changed.outputs.frontend_changed == 'True' uses: actions/setup-node@v2 with: node-version: 18 cache: yarn - name: Install dependencies if: steps.check_file_changed.outputs.frontend_changed == 'True' uses: borales/actions-yarn@v3.0.0 with: cmd: install - name: Install additional dependencies rollup-linux-x64-gnu if: steps.check_file_changed.outputs.frontend_changed == 'True' run : sudo yarn add @rollup/rollup-linux-x64-gnu - name: Build frontend pkg if: steps.check_file_changed.outputs.frontend_changed == 'True' run: sudo yarn build:frontend build-and-push-gear-node-image: if: github.event.pull_request.draft == false runs-on: ubuntu-latest needs: [check-labels] environment: dev permissions: contents: read packages: write steps: - name: Checkout repository uses: actions/checkout@v2 - name: Log in to the github container registry uses: docker/login-action@master with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Gear node Docker image uses: docker/build-push-action@master with: file: k8s/gear-node/Dockerfile push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-node:dev build-and-push-indexer-image: if: github.event.pull_request.draft == false runs-on: ubuntu-latest needs: [check-labels] environment: dev permissions: contents: read packages: write steps: - name: Checkout repository uses: actions/checkout@v2 - name: Log in to the github container registry uses: docker/login-action@master with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Indexer Docker image uses: docker/build-push-action@master with: file: idea/indexer/Dockerfile push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-indexer:dev build-and-push-api-gateway-image: if: github.event.pull_request.draft == false runs-on: ubuntu-latest needs: [check-labels] environment: dev permissions: contents: read packages: write steps: - name: Checkout repository uses: actions/checkout@v2 - name: Log in to the github container registry uses: docker/login-action@master with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Api Gateway Docker image uses: docker/build-push-action@master with: file: idea/api-gateway/Dockerfile push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-api-gateway:dev build-and-push-meta-storage-image: if: github.event.pull_request.draft == false runs-on: ubuntu-latest needs: [check-labels] environment: dev permissions: contents: read packages: write steps: - name: Checkout repository uses: actions/checkout@v2 - name: Log in to the github container registry uses: docker/login-action@master with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Meta Storage Docker image uses: docker/build-push-action@master with: file: idea/meta-storage/Dockerfile push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-meta-storage:dev build-and-push-test-balance-image: if: github.event.pull_request.draft == false runs-on: ubuntu-latest needs: [check-labels] environment: dev permissions: contents: read packages: write steps: - name: Checkout repository uses: actions/checkout@v2 - name: Log in to the github container registry uses: docker/login-action@master with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Test Balance Docker image uses: docker/build-push-action@master with: file: idea/test-balance/Dockerfile push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-test-balance:dev purge-k8s-test-env: if: github.event.pull_request.draft == false needs: [ build-and-push-indexer-image, build-and-push-api-gateway-image, build-and-push-meta-storage-image, build-and-push-test-balance-image, build-and-push-gear-node-image ] runs-on: ubuntu-latest steps: - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }} aws-region: ${{ env.AWS_REGION }} - name: Restart RabbitMQ uses: sergeyfilyanin/kubectl-aws-eks@master with: args: rollout restart deployment rabbitmq -n $KUBE_NAMESPACE - name: Check RabbitMQ uses: sergeyfilyanin/kubectl-aws-eks@master with: args: rollout status deployment rabbitmq -n $KUBE_NAMESPACE --timeout=120s - name: Deploy to k8s uses: sergeyfilyanin/kubectl-aws-eks@master with: args: rollout restart deployment gear-node api-gateway-testenv frontend-nginx-testenv postgres-testenv postgres-testbalance-testenv postgres-meta-testenv -n $KUBE_NAMESPACE - name: Check k8s deployments uses: sergeyfilyanin/kubectl-aws-eks@master with: args: get deployment -o name -n $KUBE_NAMESPACE | xargs -n1 -t kubectl rollout status -n $KUBE_NAMESPACE --timeout=120s - name: Deploy to k8s indexer uses: sergeyfilyanin/kubectl-aws-eks@master with: args: rollout restart deployment test-balance-testenv indexer-testenv meta-storage -n $KUBE_NAMESPACE - name: Check k8s deployment test-balance-testenv uses: sergeyfilyanin/kubectl-aws-eks@master with: args: rollout status deployment test-balance-testenv -n $KUBE_NAMESPACE --timeout=120s - name: Check k8s deployment indexer uses: sergeyfilyanin/kubectl-aws-eks@master with: args: rollout status deployment indexer-testenv -n $KUBE_NAMESPACE --timeout=120s - name: Check k8s deployment meta-storage uses: sergeyfilyanin/kubectl-aws-eks@master with: args: rollout status deployment meta-storage -n $KUBE_NAMESPACE --timeout=120s run-e2e-tests: if: github.event.pull_request.draft == false needs: [purge-k8s-test-env] runs-on: ubuntu-latest environment: dev env: RUSTUP_HOME: /tmp/rustup_home steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install NodeJS 20.x uses: actions/setup-node@v2.1.5 with: node-version: 20.x - name: Set up Rust uses: dtolnay/rust-toolchain@stable with: targets: wasm32-unknown-unknown - name: "Prepare: Build test programs" working-directory: api/programs run: cargo build --release - name: "Prepare: Copy built programs" run: cp api/programs/target/wasm32-unknown-unknown/release/* idea/tests/wasm-test - name: "Prepare: Build test programs" working-directory: idea/tests/programs run: cargo build --release - name: "Install dependencies" run: YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install - name: "Build: @gear-js/common" run: yarn build:common - name: "Run tests" timeout-minutes: 7 working-directory: idea/tests env: API_ENDPOINT: ${{ secrets.API_ADDRESS_URL_TEST }} WS_PROVIDER: ${{ secrets.WS_PROVIDER_URL_TEST }} WS_PROVIDER_VARA: ${{ secrets.WS_PROVIDER_VARA_URL_TEST }} TEST_ENV: ${{ secrets.TEST_ENV }} run: yarn test