From fbe078122926d410db8adefb874fffc468af081a Mon Sep 17 00:00:00 2001 From: Djuri Baars Date: Sat, 3 May 2025 18:48:32 +0200 Subject: [PATCH] fix: workflow fixes --- .forgejo/workflows/build.yaml | 8 ++++---- gzip_build.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 gzip_build.py diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index c14d6e5..ac7cc96 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -41,15 +41,15 @@ jobs: with: token: ${{ secrets.GH_TOKEN }} node-version: lts/* - cache: yarn - cache-dependency-path: '**/yarn.lock' + cache: pnpm + cache-dependency-path: '**/pnpm-lock.yaml' - uses: actions/cache@v4 with: path: | ~/.cache/pip ~/node_modules ~/.cache/ms-playwright - key: ${{ runner.os }}-pio-playwright-${{ hashFiles('**/yarn.lock') }} + key: ${{ runner.os }}-pio-playwright-${{ hashFiles('**/pnpm-lock.yaml') }} - name: Get current date id: dateAndTime run: echo "dateAndTime=$(date +'%Y-%m-%d-%H:%M')" >> $GITHUB_OUTPUT @@ -71,7 +71,7 @@ jobs: - name: Run Playwright tests run: npx playwright test - name: Build WebUI - run: yarn build + run: pnpm build # The following steps only run on push to main - name: Get current block diff --git a/gzip_build.py b/gzip_build.py new file mode 100644 index 0000000..f583c63 --- /dev/null +++ b/gzip_build.py @@ -0,0 +1,28 @@ +import os +import gzip +from shutil import copyfileobj +from pathlib import Path + +def gzip_file(input_file, output_file): + with open(input_file, 'rb') as f_in: + with gzip.open(output_file, 'wb') as f_out: + copyfileobj(f_in, f_out) + +def process_directory(input_dir, output_dir): + for root, dirs, files in os.walk(input_dir): + relative_path = os.path.relpath(root, input_dir) + output_root = os.path.join(output_dir, relative_path) + + Path(output_root).mkdir(parents=True, exist_ok=True) + + for file in files: + # if file.endswith(('.html', '.css', '.js')): + input_file_path = os.path.join(root, file) + output_file_path = os.path.join(output_root, file + '.gz') + gzip_file(input_file_path, output_file_path) + print(f'Compressed: {input_file_path} -> {output_file_path}') + +input_directory = 'dist' +output_directory = 'build_gz' + +process_directory(input_directory, output_directory) \ No newline at end of file