From 69b06a648a6c50b658f323a28b7c0eac5bb8d1e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Guti=C3=A9rrez=20Hermoso?= Date: Tue, 11 Jun 2024 22:08:43 -0400 Subject: [PATCH] wip --- .github/workflows/docker.yml | 28 ++++++++++++++++--- .github/workflows/docker_latest.yml | 41 +++++++++++++++++++++++++--- .grist-ee-version | 1 + buildtools/build.sh | 10 +++++++ buildtools/checkout-ext-directory.sh | 17 ++++++++++++ 5 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 .grist-ee-version create mode 100755 buildtools/checkout-ext-directory.sh diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ef1f5d7ba72..fcabebf4e79 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -8,17 +8,32 @@ on: jobs: push_to_registry: - name: Push Docker image to Docker Hub + name: Push Docker images to Docker Hub runs-on: ubuntu-latest + strategy: + matrix: + image: + - name: "grist-oss" + repo: "grist-core" + - name: "grist" + repo: "grist-ee" + # For now, we build it twice. + - name: "grist-ee" + repo: "grist-ee" steps: - name: Check out the repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 + + - name: Check out the ext/ directory + if: matrix.image.name != 'grist-oss' + run: buildtools/checkout-ext-directory.sh ${{ matrix.image.repo }} + - name: Docker meta id: meta uses: docker/metadata-action@v4 with: images: | - ${{ github.repository_owner }}/grist + ${{ github.repository_owner }}/${{ matrix.image.name }} tags: | type=ref,event=branch type=ref,event=pr @@ -28,13 +43,16 @@ jobs: stable - name: Set up QEMU uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + - name: Log in to Docker Hub - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + - name: Push to Docker Hub uses: docker/build-push-action@v2 with: @@ -44,3 +62,5 @@ jobs: tags: ${{ steps.meta.outputs.tags }} cache-from: type=gha cache-to: type=gha,mode=max + build-contexts: ${{ matrix.image.name != 'grist-oss' && 'ext=ext' || '' }} + diff --git a/.github/workflows/docker_latest.yml b/.github/workflows/docker_latest.yml index 5b79ef03a11..2be1ebf2c2d 100644 --- a/.github/workflows/docker_latest.yml +++ b/.github/workflows/docker_latest.yml @@ -10,6 +10,12 @@ on: # Run at 5:41 UTC daily - cron: '41 5 * * *' workflow_dispatch: + inputs: + latest_branch: + description: Branch from which to create the latest Docker image + type: string + required: true + default_value: latest_candidate jobs: push_to_registry: @@ -19,54 +25,81 @@ jobs: matrix: python-version: [3.9] node-version: [18.x] + image: + - name: "grist-oss" + repo: "grist-core" + - name: "grist" + repo: "grist-ee" + # For now, we build it twice. + - name: "grist-ee" + repo: "grist-ee" steps: - name: Check out the repo uses: actions/checkout@v2 with: - ref: latest_candidate + ref: ${{ inputs.latest_branch }} + + - name: Check out the ext/ directory + if: matrix.image.name != 'grist-oss' + run: buildtools/checkout-ext-directory.sh ${{ matrix.image.repo }} + + - name: Set up QEMU uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + - name: Prepare image but do not push it yet uses: docker/build-push-action@v2 with: context: . load: true - tags: ${{ github.repository_owner }}/grist:latest + tags: ${{ github.repository_owner }}/${{ matrix.image.name }}:latest cache-from: type=gha + build-contexts: ${{ matrix.image.name != 'grist-oss' && 'ext=ext' || '' }} + - name: Use Node.js ${{ matrix.node-version }} for testing uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} + - name: Set up Python ${{ matrix.python-version }} for testing - maybe not needed uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + - name: Install Python packages run: | pip install virtualenv yarn run install:python + - name: Install Node.js packages run: yarn install + - name: Build Node.js code run: yarn run build:prod + - name: Run tests - run: TEST_IMAGE=${{ github.repository_owner }}/grist VERBOSE=1 DEBUG=1 MOCHA_WEBDRIVER_HEADLESS=1 yarn run test:docker + run: TEST_IMAGE=${{ github.repository_owner }}/${{ matrix.image.name }} VERBOSE=1 DEBUG=1 MOCHA_WEBDRIVER_HEADLESS=1 yarn run test:docker + - name: Log in to Docker Hub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + - name: Push to Docker Hub uses: docker/build-push-action@v2 with: context: . platforms: linux/amd64,linux/arm64/v8 push: true - tags: ${{ github.repository_owner }}/grist:latest + tags: ${{ github.repository_owner }}/{{ matrix.image.name }}:latest cache-from: type=gha cache-to: type=gha,mode=max + build-contexts: ${{ matrix.image.name != 'grist-oss' && 'ext=ext' || '' }} + - name: Update latest branch uses: ad-m/github-push-action@8407731efefc0d8f72af254c74276b7a90be36e1 with: diff --git a/.grist-ee-version b/.grist-ee-version new file mode 100644 index 00000000000..f374f6662e9 --- /dev/null +++ b/.grist-ee-version @@ -0,0 +1 @@ +0.9.1 diff --git a/buildtools/build.sh b/buildtools/build.sh index c87643a6465..d09d3a3d5b6 100755 --- a/buildtools/build.sh +++ b/buildtools/build.sh @@ -5,7 +5,17 @@ set -e PROJECT="" if [[ -e ext/app ]]; then PROJECT="tsconfig-ext.json" + echo "Using extra app directory" + if [[ -e ext/package.json ]]; then + pushd ext + yarn install --frozen-lockfile + mv node_modules ../.. + popd + fi +else + echo "No extra app directory found" fi + WEBPACK_CONFIG=buildtools/webpack.config.js if [[ -e ext/buildtools/webpack.config.js ]]; then # Allow webpack config file to be replaced (useful diff --git a/buildtools/checkout-ext-directory.sh b/buildtools/checkout-ext-directory.sh new file mode 100755 index 00000000000..68be38ada13 --- /dev/null +++ b/buildtools/checkout-ext-directory.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# This checks out the ext/ directory from the extra repo (e.g. +# grist-ee or grist-desktop) depending on the supplied repo name. + +set -e + +repo=$1 +ref=$(cat .$repo-version) + +git clone --branch $ref --depth 1 --filter=tree:0 "https://github.com/gristlabs/$repo" +pushd $repo +git sparse-checkout set ext +git checkout +popd +mv $repo/ext . +rm -rf $repo