From 32679959bab43c44700117bd06a6ea1ba502c09f Mon Sep 17 00:00:00 2001 From: neil Date: Wed, 25 Jan 2023 14:58:19 +0800 Subject: [PATCH 1/8] #172 ci cache implementation: pnpm store and cargo build target --- .github/workflows/ci.yml | 20 ++++++++++++++++++-- devops/linux-builder/Dockerfile | 5 +++++ devops/linux-builder/action.yml | 18 ++++++++++++++++++ devops/linux-builder/entrypoint.sh | 3 +++ devops/ubuntu/Dockerfile | 14 ++++++++++++-- modules/gui/src/routes/+layout.svelte | 7 ------- 6 files changed, 56 insertions(+), 11 deletions(-) create mode 100644 devops/linux-builder/Dockerfile create mode 100644 devops/linux-builder/action.yml create mode 100755 devops/linux-builder/entrypoint.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 601c543..3d51a0f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,8 +67,15 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: cache gui linux + uses: actions/cache@v3 + with: + key: linux+x86-64-20-pnpm-cargo + path: | + ./pnpm + ./target - name: build tauri for Linux - uses: docker://getneil/tea-builder:latest + uses: ./devops/linux-builder - uses: aws-actions/configure-aws-credentials@v1 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} @@ -120,6 +127,15 @@ jobs: - uses: teaxyz/setup@v0 if: startsWith(matrix.platform.name, 'darwin') + - name: cache gui build + uses: actions/cache@v3 + with: + key: ${{matrix.platform.name}}-pnpm-cargo + path: | + ./pnpm + ./target + # - name: build tauri for Linux + # uses: ./devops/linux-build - name: build tauri for MacOS if: startsWith(matrix.platform.name, 'darwin') # FROM: https://tauri.app/v1/guides/distribution/sign-macos @@ -134,7 +150,7 @@ jobs: - name: build tauri for Linux if: startsWith(matrix.platform.name, 'linux') # TODO: https://tauri.app/v1/guides/distribution/sign-linux - uses: docker://getneil/tea-builder:latest + uses: ./devops/linux-builder - run: tar -czvf artifacts.tgz -C ./modules/gui/src-tauri/target/release/bundle . diff --git a/devops/linux-builder/Dockerfile b/devops/linux-builder/Dockerfile new file mode 100644 index 0000000..f1be13e --- /dev/null +++ b/devops/linux-builder/Dockerfile @@ -0,0 +1,5 @@ +FROM getneil/tea-builder:bincache + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/devops/linux-builder/action.yml b/devops/linux-builder/action.yml new file mode 100644 index 0000000..e1c90cb --- /dev/null +++ b/devops/linux-builder/action.yml @@ -0,0 +1,18 @@ +name: 'build-gui-linux' +description: 'Tea GUI builder for linux' +# TODO: cache +# inputs: +# who-to-greet: # id of input +# description: 'Who to greet' +# required: true +# default: 'World' +# outputs: +# time: # id of output +# description: 'The time we greeted you' +runs: + using: 'docker' + image: 'Dockerfile' + env: + CARGO_TARGET_DIR: /github/workspace/target + args: + - ${{ inputs.who-to-greet }} \ No newline at end of file diff --git a/devops/linux-builder/entrypoint.sh b/devops/linux-builder/entrypoint.sh new file mode 100755 index 0000000..2af50bd --- /dev/null +++ b/devops/linux-builder/entrypoint.sh @@ -0,0 +1,3 @@ +#!/bin/sh -l +tea -SE xc setup +tea -SE xc build \ No newline at end of file diff --git a/devops/ubuntu/Dockerfile b/devops/ubuntu/Dockerfile index 27822a2..6b6d640 100644 --- a/devops/ubuntu/Dockerfile +++ b/devops/ubuntu/Dockerfile @@ -7,11 +7,21 @@ RUN apt-get install -y libgtk-3-dev webkit2gtk-4.0 RUN apt-get install -y --fix-missing libappindicator3-dev librsvg2-dev RUN apt-get install -y --fix-missing patchelf pkg-config curl libatomic1 gcc-multilib libsoup-gnome2.4 RUN apt-get install -y libjavascriptcoregtk-4.0-dev wget + RUN curl https://tea.xyz -o ./tea.sh RUN chmod +x tea.sh RUN ./tea.sh --yes -# Copies your code file from your action repository to the filesystem path `/` of the container -COPY entrypoint.sh /entrypoint.sh + +RUN mkdir -p /tmp/app/.git +COPY README.md /tmp/app/README.md +COPY package.json /tmp/app/package.json + +RUN tea +nodejs.org +RUN tea +pnpm.io +RUN tea +rust-lang.org +RUN tea +rust-lang.org/cargo +RUN tea +xcfile.dev # Code file to execute when the docker container starts up (`entrypoint.sh`) +COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/modules/gui/src/routes/+layout.svelte b/modules/gui/src/routes/+layout.svelte index 82fd45b..1da402c 100644 --- a/modules/gui/src/routes/+layout.svelte +++ b/modules/gui/src/routes/+layout.svelte @@ -74,13 +74,6 @@ padding: 0vw 3.33vw; } } - header { - position: absolute; - top: 0px; - left: 0px; - width: 100%; - height: 40px; - } slot { z-index: 1; From 0f838ba520f6642774daa7d5b463e08a04ef6517 Mon Sep 17 00:00:00 2001 From: neil Date: Wed, 25 Jan 2023 15:31:57 +0800 Subject: [PATCH 2/8] rerun --- .github/workflows/ci.yml | 8 ++++---- .gitignore | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d51a0f..f4b8d89 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,12 +112,12 @@ jobs: strategy: matrix: platform: - - os: macos-11 - name: darwin+x86-64 + # - os: macos-11 + # name: darwin+x86-64 - os: ubuntu-latest name: linux+x86-64 - - os: [self-hosted, macOS, ARM64] - name: darwin+aarch64 + # - os: [self-hosted, macOS, ARM64] + # name: darwin+aarch64 # err: Package atk was not found in the pkg-config search path. # requires atk >= 2.18 # - os: [self-hosted, linux, ARM64] diff --git a/.gitignore b/.gitignore index 21bcdde..eeab4fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules yarn-error.log .DS_Store -.pnpm-store \ No newline at end of file +.pnpm-store +target \ No newline at end of file From 0194ae194487d1e27776c21a35743a5a938852c1 Mon Sep 17 00:00:00 2001 From: neil Date: Wed, 25 Jan 2023 15:50:31 +0800 Subject: [PATCH 3/8] correct tgz path --- .github/workflows/ci.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4b8d89..bb4318b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,12 +112,12 @@ jobs: strategy: matrix: platform: - # - os: macos-11 - # name: darwin+x86-64 + - os: macos-11 + name: darwin+x86-64 - os: ubuntu-latest name: linux+x86-64 - # - os: [self-hosted, macOS, ARM64] - # name: darwin+aarch64 + - os: [self-hosted, macOS, ARM64] + name: darwin+aarch64 # err: Package atk was not found in the pkg-config search path. # requires atk >= 2.18 # - os: [self-hosted, linux, ARM64] @@ -140,6 +140,7 @@ jobs: if: startsWith(matrix.platform.name, 'darwin') # FROM: https://tauri.app/v1/guides/distribution/sign-macos env: + CARGO_TARGET_DIR: /github/workspace/target GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ENABLE_CODE_SIGNING: ${{ secrets.GUI_APPLE_CERTIFICATE }} APPLE_CERTIFICATE: ${{ secrets.GUI_APPLE_CERTIFICATE }} @@ -152,7 +153,7 @@ jobs: # TODO: https://tauri.app/v1/guides/distribution/sign-linux uses: ./devops/linux-builder - - run: tar -czvf artifacts.tgz -C ./modules/gui/src-tauri/target/release/bundle . + - run: tar -czvf artifacts.tgz -C ./target/release/bundle . - name: upload artifacts uses: actions/upload-artifact@v3 From 6c9d3ae6f7c1d49b75908f7be946e7e1ea2cffd4 Mon Sep 17 00:00:00 2001 From: neil Date: Wed, 25 Jan 2023 16:06:07 +0800 Subject: [PATCH 4/8] change relative path --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb4318b..baeb50f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -140,7 +140,7 @@ jobs: if: startsWith(matrix.platform.name, 'darwin') # FROM: https://tauri.app/v1/guides/distribution/sign-macos env: - CARGO_TARGET_DIR: /github/workspace/target + CARGO_TARGET_DIR: ./target GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ENABLE_CODE_SIGNING: ${{ secrets.GUI_APPLE_CERTIFICATE }} APPLE_CERTIFICATE: ${{ secrets.GUI_APPLE_CERTIFICATE }} From b4863f80eb69db420c1fbc8f8fc7f70627144f9c Mon Sep 17 00:00:00 2001 From: neil Date: Wed, 25 Jan 2023 16:14:05 +0800 Subject: [PATCH 5/8] workspace env --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index baeb50f..72bce19 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -140,7 +140,7 @@ jobs: if: startsWith(matrix.platform.name, 'darwin') # FROM: https://tauri.app/v1/guides/distribution/sign-macos env: - CARGO_TARGET_DIR: ./target + CARGO_TARGET_DIR: ${{ GITHUB_WORKSPACE }}/target GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ENABLE_CODE_SIGNING: ${{ secrets.GUI_APPLE_CERTIFICATE }} APPLE_CERTIFICATE: ${{ secrets.GUI_APPLE_CERTIFICATE }} From 134656552b036a02e6d9685286106fcdd125d005 Mon Sep 17 00:00:00 2001 From: neil Date: Wed, 25 Jan 2023 16:16:02 +0800 Subject: [PATCH 6/8] correct ref --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 72bce19..3caede3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -140,7 +140,7 @@ jobs: if: startsWith(matrix.platform.name, 'darwin') # FROM: https://tauri.app/v1/guides/distribution/sign-macos env: - CARGO_TARGET_DIR: ${{ GITHUB_WORKSPACE }}/target + CARGO_TARGET_DIR: ${{ github.workspace }}/target GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ENABLE_CODE_SIGNING: ${{ secrets.GUI_APPLE_CERTIFICATE }} APPLE_CERTIFICATE: ${{ secrets.GUI_APPLE_CERTIFICATE }} From b4418eaa28ec050db344da6a33af6f522f41443d Mon Sep 17 00:00:00 2001 From: neil Date: Wed, 25 Jan 2023 16:29:54 +0800 Subject: [PATCH 7/8] disable cache in self hosted runner --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3caede3..7e7c23b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -128,6 +128,10 @@ jobs: if: startsWith(matrix.platform.name, 'darwin') - name: cache gui build + # TODO: cache issue in our self-hosted macos runner ESPIPE: invalid seek, read + # but its ok to ignore, its still the fastest builder + # NOTE: enabling cache in the self hosted runner slows down the pipeline by 4m because post-cache builder error ^ + if: startsWith(matrix.platform.name, 'linux') || matrix.platform.name == 'darwin+x86-64' uses: actions/cache@v3 with: key: ${{matrix.platform.name}}-pnpm-cargo From b89ba8b8de551281bd4c70d67a50ad686e89e889 Mon Sep 17 00:00:00 2001 From: neil Date: Wed, 25 Jan 2023 17:32:54 +0800 Subject: [PATCH 8/8] #172 caching in main pipeline --- .github/workflows/main.yml | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ae25d6b..89f0942 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,6 +36,13 @@ jobs: - uses: actions/checkout@v3 with: persist-credentials: false + - name: cache gui linux + uses: actions/cache@v3 + with: + key: linux+x86-64-20-pnpm-cargo-main + path: | + ./pnpm + ./target - name: build tauri for Linux if: startsWith(matrix.platform.name, 'linux') uses: docker://getneil/tea-builder:latest @@ -59,11 +66,22 @@ jobs: - uses: actions/checkout@v3 - uses: teaxyz/setup@v0 if: startsWith(matrix.platform.name, 'darwin') - + - name: cache gui build + # TODO: cache issue in our self-hosted macos runner ESPIPE: invalid seek, read + # but its ok to ignore, its still the fastest builder + # NOTE: enabling cache in the self hosted runner slows down the pipeline by 4m because post-cache builder error ^ + if: startsWith(matrix.platform.name, 'linux') || matrix.platform.name == 'darwin+x86-64' + uses: actions/cache@v3 + with: + key: ${{matrix.platform.name}}-pnpm-cargo-main + path: | + ./pnpm + ./target - name: build tauri for MacOS if: startsWith(matrix.platform.name, 'darwin') run: tea -ES xc build env: + CARGO_TARGET_DIR: ${{ github.workspace }}/target GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ENABLE_CODE_SIGNING: ${{ secrets.GUI_APPLE_CERTIFICATE }} APPLE_CERTIFICATE: ${{ secrets.GUI_APPLE_CERTIFICATE }} @@ -73,9 +91,9 @@ jobs: - name: build tauri for Linux if: startsWith(matrix.platform.name, 'linux') # TODO: https://tauri.app/v1/guides/distribution/sign-linux - uses: docker://getneil/tea-builder:latest + uses: ./devops/linux-builder - - run: tar -czvf artifacts.tgz -C ./modules/gui/src-tauri/target/release/bundle . + - run: tar -czvf artifacts.tgz -C ./target/release/bundle . - name: upload artifacts uses: actions/upload-artifact@v3