diff --git a/.github/workflows/images.yml b/.github/workflows/images.yml index ac86f985b3..a239abd82a 100644 --- a/.github/workflows/images.yml +++ b/.github/workflows/images.yml @@ -1,9 +1,7 @@ name: Build and Push Images on: - push: - branches: - - main + workflow_call: release: types: [published] @@ -21,9 +19,10 @@ jobs: password: ${{ secrets.botDockerHubPassword }} - name: Build and push (latest) + if: github.ref == 'refs/heads/main' uses: docker/build-push-action@v3 with: - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64,linux/arm64 push: true tags: instill/console:latest cache-from: type=registry,ref=instill/console:buildcache @@ -85,7 +84,7 @@ jobs: if: github.event_name == 'release' uses: docker/build-push-action@v3 with: - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64,linux/arm64 push: true tags: instill/console:${{steps.set_version.outputs.no_v_tag}} cache-from: type=registry,ref=instill/console:buildcache diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml new file mode 100644 index 0000000000..6976103247 --- /dev/null +++ b/.github/workflows/integration-test.yml @@ -0,0 +1,118 @@ +name: Integration Test + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build-push-image: + if: github.ref == 'refs/heads/main' + name: Build and push image + uses: instill-ai/console/.github/workflows/images.yml@main + secrets: inherit + backends: + needs: build-push-image + if: github.ref == 'refs/heads/main' + name: Backends + strategy: + fail-fast: false + matrix: + component: [pipeline, connector, model, mgmt] + uses: instill-ai/vdp/.github/workflows/integration-test-backend.yml@main + with: + component: ${{ matrix.component }} + target: latest + console: + needs: build-push-image + if: github.ref == 'refs/heads/main' + name: Console + uses: instill-ai/vdp/.github/workflows/integration-test-console.yml@main + with: + target: latest + + pr-head: + if: github.event_name == 'pull_request' + name: PR head branch + runs-on: ubuntu-latest + steps: + + # mono occupies port 8084 which conflicts with mgmt-backend + - name: Stop mono service + run: | + sudo kill -9 `sudo lsof -t -i:8084` + sudo lsof -i -P -n | grep LISTEN + + - name: Free disk space + run: | + df --human-readable + sudo apt clean + docker rmi $(docker image ls --all --quiet) + rm --recursive --force "$AGENT_TOOLSDIRECTORY" + df --human-readable + + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Load .env file + uses: cardinalby/export-env-action@v2 + with: + envFile: .env + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: dropletbot + password: ${{ secrets.botDockerHubPassword }} + + - name: Build image + uses: docker/build-push-action@v3 + with: + context: . + load: true + tags: instill/console:latest + + - name: Checkout (vdp) + uses: actions/checkout@v3 + with: + repository: instill-ai/vdp + + - name: Launch VDP + run: | + COMPOSE_PROFILES=all \ + EDITION=local-ce:test \ + ITMODE=true \ + TRITON_CONDA_ENV_PLATFORM=cpu \ + CONSOLE_BASE_URL_HOST=console \ + CONSOLE_BASE_API_GATEWAY_URL_HOST=api-gateway \ + docker compose -f docker-compose.yml -f docker-compose.latest.yml up -d --quiet-pull + COMPOSE_PROFILES=all \ + EDITION=local-ce:test \ + docker compose -f docker-compose.yml -f docker-compose.latest.yml rm -f + + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Run integration-test + run: | + docker build --build-arg TEST_USER='root' -f Dockerfile.playwright -t console-playwright . + docker run -t --rm \ + -e NEXT_PUBLIC_CONSOLE_BASE_URL=http://console:3000 \ + -e NEXT_PUBLIC_API_GATEWAY_BASE_URL=http://api-gateway:8080 \ + -e NEXT_SERVER_API_GATEWAY_BASE_URL=http://api-gateway:8080 \ + -e NEXT_PUBLIC_API_VERSION=v1alpha \ + -e NEXT_PUBLIC_SELF_SIGNED_CERTIFICATION=false \ + -e NEXT_PUBLIC_INSTILL_AI_USER_COOKIE_NAME=instill-ai-user \ + --network instill-network \ + --entrypoint ./entrypoint-playwright.sh \ + --name console-integration-test console-playwright diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f193a0ce1b..d31f6d1b8d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,10 +22,12 @@ jobs: config-file: release-please/config.json manifest-file: release-please/manifest.json - uses: actions/checkout@v2 + if: ${{ steps.release.outputs.release_created }} with: token: ${{ secrets.botGitHubToken }} - name: Import GPG Key - uses: crazy-max/ghaction-import-gpg@v4 + if: ${{ steps.release.outputs.release_created }} + uses: crazy-max/ghaction-import-gpg@v5 with: gpg_private_key: ${{ secrets.botGPGPrivateKey }} passphrase: ${{ secrets.botGPGPassphrase }} @@ -43,4 +45,4 @@ jobs: git tag -a v${{ steps.release.outputs.major }} -m "Release v${{ steps.release.outputs.major }} pointing to tag ${{ steps.release.outputs.tag_name }}" git tag -a v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} -m "Release v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} pointing to tag ${{ steps.release.outputs.tag_name }}" git push origin v${{ steps.release.outputs.major }} - git push origin v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} \ No newline at end of file + git push origin v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} diff --git a/.github/workflows/pr-semantic.yml b/.github/workflows/semantic.yml similarity index 94% rename from .github/workflows/pr-semantic.yml rename to .github/workflows/semantic.yml index ad6df65f2a..9e330e58cb 100644 --- a/.github/workflows/pr-semantic.yml +++ b/.github/workflows/semantic.yml @@ -1,4 +1,4 @@ -name: "Lint PR" +name: Lint PR on: pull_request_target: diff --git a/README.md b/README.md index ad72f64680..26044fc858 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Versatile Data Pipeline (VDP) console +[![Integration Test](https://github.com/instill-ai/console/actions/workflows/integration-test.yml/badge.svg)](https://github.com/instill-ai/console/actions/workflows/integration-test.yml) + ## About VDP Console The VDP console is written in Nextjs, Typescript, TailwindCSS and it runs a docker container with the VDP backend. Interested in trying it out? Check out [here](https://github.com/instill-ai/vdp) to run it locally. @@ -105,3 +107,14 @@ Please refer to the console integration test [document](/integration-test/README ### net::ERR_CERT_AUTHORITY_INVALID During the local development, our whole backends use self-signed certification. The browser will complain about with `net::ERR_CERT_AUTHORITY_INVALID` error. Please proceed to the API-gateway URL (default: https://localhost:8080) and tell your browser that you want to proceed with the request under this url. + +### CI/CD + +- **pull_request** to the `main` branch will trigger the **`Integration Test`** workflow running the integration test using the image built on the PR head branch. +- **push** to the `main` branch will trigger + - the **`Integration Test`** workflow building and pushing the `:latest` image on the `main` branch, following by running the integration test, and + - the **`Release Please`** workflow, which will create and update a PR with respect to the up-to-date `main` branch using [release-please-action](https://github.com/google-github-actions/release-please-action). + +Once the release PR is merged to the `main` branch, the [release-please-action](https://github.com/google-github-actions/release-please-action) will tag and release a version correspondingly. + +The images are pushed to Docker Hub [repository](https://hub.docker.com/r/instill/console).