From 7302fa6ecea83e3342b0f718aa27a8ed8f7d9fd1 Mon Sep 17 00:00:00 2001 From: Marcel Kost Date: Thu, 6 Jun 2024 11:35:20 +0200 Subject: [PATCH] Fix deployment by downloading lang_docs with curl instead of typescript The download of the lang_docs zip packages with typescript suddenly started failing and we couldn't figure out why. The download itself succeeded, while the downloaded files were empty. To work around the issue, the downloading script now uses curl to do the actual download. Typescript is still used to generate the curl command line, as the information for the download is only available in typescript. --- .github/workflows/deploy.yaml | 8 ++++---- website/download_links.ts | 27 ++++++--------------------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index a7d3f04..6010998 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -52,6 +52,10 @@ jobs: working-directory: main/website run: yarn install --frozen-lockfile + - name: Install dependencies (upcoming) + working-directory: upcoming/website + run: yarn install --frozen-lockfile + - name: Download language docs working-directory: main/website run: yarn ts-node download_links.ts docs_py docs_cxx docs_java @@ -63,10 +67,6 @@ jobs: GITHUB_ORIGIN: ${{ steps.setup-pages.outputs.origin }} GITHUB_BASE_PATH: ${{ steps.setup-pages.outputs.base_path }} - - name: Install dependencies (upcoming) - working-directory: upcoming/website - run: yarn install --frozen-lockfile - - name: Build webpage for `upcoming` branch working-directory: upcoming/website run: yarn build diff --git a/website/download_links.ts b/website/download_links.ts index 4fd4137..e3d510e 100644 --- a/website/download_links.ts +++ b/website/download_links.ts @@ -1,33 +1,18 @@ -import https from 'https'; -import fs from 'fs'; import { config } from './src/config'; +import { spawn } from 'child_process'; function downloadFile(targetPath: string, url: string) { - console.log(`Downloading ${url}`); - return new Promise(( resolve, reject ) => { - const file = fs.createWriteStream(targetPath); - const request = https.get(url, function(response) { - response.pipe(file); - - // after download completed close filestream - file.on("finish", () => { - file.close(); - console.log("Download Completed"); - resolve(); - }); - file.on('error', (e)=> { - file.close(); - reject(e); - }); - }); - }); + const cmd = `curl --output ${targetPath} ${url}` + console.log(`Downloading ${url} to ${targetPath}`); + console.log(cmd) + spawn(cmd, [], { shell: true, stdio: 'inherit' }) } async function downloadArtifact(artifactName: string) { const url = config.download[artifactName]; if(!url) throw `Unknown artifact ${artifactName}` const fileSuffix = url.split(".").slice(-1); - await downloadFile(artifactName + "." + fileSuffix, url) + downloadFile(artifactName + "." + fileSuffix, url) } async function doDownloads() {