From 7c3cb9aeb1954241f4ac0a4009eb24896577a174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kinen?= Date: Tue, 18 Jun 2024 17:08:38 +0300 Subject: [PATCH 1/7] Add build check --- .github/workflows/run_tests.yml | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 .github/workflows/run_tests.yml diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml new file mode 100755 index 0000000..a795301 --- /dev/null +++ b/.github/workflows/run_tests.yml @@ -0,0 +1,38 @@ +name: Run tests + +on: + push: + branches: [ master, develop ] + pull_request: + branches: [ master, develop] + +# Cancel job when new commit is pushed for the same build +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency +# https://github.com/OSGeo/gdal/pull/5460 +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + node: [ 16 ] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} +# We need package-lock.json to use cache this way +# cache: 'npm' + - name: Install dependencies +# With package-lock.json we should use "npm ci" + run: npm install + - name: Run tests + run: npm run test + - name: Run build + run: npm run build From e7baee57e50fbcb05c44926d23dd04e55b07ba2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kinen?= Date: Tue, 18 Jun 2024 17:13:57 +0300 Subject: [PATCH 2/7] Generate some metadata before build --- .github/workflows/run_tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index a795301..130124e 100755 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -34,5 +34,7 @@ jobs: run: npm install - name: Run tests run: npm run test + - name: Generate docs metadata + run: npm run metadata - name: Run build run: npm run build From df19c880fc30555c38ce60ef4c030dd3239a6148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kinen?= Date: Tue, 18 Jun 2024 17:31:08 +0300 Subject: [PATCH 3/7] Generate dummy index.js for GH actions --- .github/workflows/run_tests.yml | 2 ++ package.json | 1 + scripts/generateDummyVersions.js | 14 ++++++++++++++ 3 files changed, 17 insertions(+) create mode 100644 scripts/generateDummyVersions.js diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 130124e..d925f70 100755 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -36,5 +36,7 @@ jobs: run: npm run test - name: Generate docs metadata run: npm run metadata + - name: Generate dummy docs metadata + run: npm run dummy_docs - name: Run build run: npm run build diff --git a/package.json b/package.json index 9a04c4b..5dae4fe 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "start": "next start", "lint": "next lint", "docs": "node scripts/runAll.js", + "dummy_docs": "node scripts/generateDummyVersions.js", "metadata": "node scripts/generateContentMetadata.js", "docsmetadata": "node scripts/generateDocumentationMetadata.js", "apidocs": "node scripts/generateApidocs.js", diff --git a/scripts/generateDummyVersions.js b/scripts/generateDummyVersions.js new file mode 100644 index 0000000..d6611d0 --- /dev/null +++ b/scripts/generateDummyVersions.js @@ -0,0 +1,14 @@ +const fs = require('fs'); +const path = require('path'); +const { generateDocumentationMetadata } = require('./documentationMetadataHelper'); + +// So build on GitHub Actions can work without cloning the documentation folders +const generateDummyDocs = (folder) => { + if (!fs.existsSync(folder)) { + fs.mkdirSync(folder, { recursive: true }); + } + generateDocumentationMetadata(folder); +}; + +generateDummyDocs('./_content/api/versions/'); +generateDummyDocs('./_content/docs/'); \ No newline at end of file From 4d1ededbee7aea2e038d66b64c83505b7e573887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kinen?= Date: Tue, 18 Jun 2024 17:46:06 +0300 Subject: [PATCH 4/7] Try disabling checks for js --- tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tsconfig.json b/tsconfig.json index cc2e9d1..6bb3c07 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,7 @@ "target": "es2015", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, + "checkJs": false, "skipLibCheck": true, "strict": true, "noEmit": true, From a963c45079fb1efafcd16372256da420cf125cd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kinen?= Date: Tue, 18 Jun 2024 17:50:28 +0300 Subject: [PATCH 5/7] Generate index.ts files instead to workaround empty array types --- scripts/documentationMetadataHelper.js | 7 +++++-- tsconfig.json | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/documentationMetadataHelper.js b/scripts/documentationMetadataHelper.js index dacc22e..edf7bc5 100644 --- a/scripts/documentationMetadataHelper.js +++ b/scripts/documentationMetadataHelper.js @@ -13,8 +13,11 @@ function generateDocumentationMetadata(fullPath) { const sortedVersions = subdirectories .sort((a, b) => parseFloat(a) - parseFloat(b)); - const indexContent = `const availableVersions = ${JSON.stringify(sortedVersions)};\n\nexport default availableVersions;`; - fs.writeFileSync(path.join(fullPath, 'index.js'), indexContent); + const indexContent = ` + const availableVersions: string[] = ${JSON.stringify(sortedVersions)}; + export default availableVersions; + `; + fs.writeFileSync(path.join(fullPath, 'index.ts'), indexContent); } exports.getSubdirectories = getSubdirectories; diff --git a/tsconfig.json b/tsconfig.json index 6bb3c07..cc2e9d1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,6 @@ "target": "es2015", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, - "checkJs": false, "skipLibCheck": true, "strict": true, "noEmit": true, From 39b6760b5f90a4a6ed9ccd44016281ce1178d37f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kinen?= Date: Tue, 18 Jun 2024 18:06:18 +0300 Subject: [PATCH 6/7] Generate dummy version doc index --- scripts/generateDummyVersions.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/generateDummyVersions.js b/scripts/generateDummyVersions.js index d6611d0..ac25dd4 100644 --- a/scripts/generateDummyVersions.js +++ b/scripts/generateDummyVersions.js @@ -3,12 +3,21 @@ const path = require('path'); const { generateDocumentationMetadata } = require('./documentationMetadataHelper'); // So build on GitHub Actions can work without cloning the documentation folders -const generateDummyDocs = (folder) => { +const generateDummyDocs = (folder, addIndex = true) => { if (!fs.existsSync(folder)) { fs.mkdirSync(folder, { recursive: true }); } - generateDocumentationMetadata(folder); + + addIndex && generateDocumentationMetadata(folder); + }; generateDummyDocs('./_content/api/versions/'); +generateDummyDocs('./_content/api/versions/latest', false); +const indexContent = ` +const allDocs = []; +export default allDocs; +`; +fs.writeFileSync(path.join('./_content/api/versions/latest/', 'index.js'), indexContent); + generateDummyDocs('./_content/docs/'); \ No newline at end of file From 99a2b9339b778c5be9c30ba62faf461e264a6947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kinen?= Date: Tue, 18 Jun 2024 18:15:38 +0300 Subject: [PATCH 7/7] Generate some dummy folders --- scripts/generateDummyVersions.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/generateDummyVersions.js b/scripts/generateDummyVersions.js index ac25dd4..dc039fa 100644 --- a/scripts/generateDummyVersions.js +++ b/scripts/generateDummyVersions.js @@ -13,11 +13,10 @@ const generateDummyDocs = (folder, addIndex = true) => { }; generateDummyDocs('./_content/api/versions/'); -generateDummyDocs('./_content/api/versions/latest', false); +generateDummyDocs('./_content/docs/latest', false); +generateDummyDocs('./_content/docs/'); const indexContent = ` -const allDocs = []; +const allDocs = ['latest']; export default allDocs; `; -fs.writeFileSync(path.join('./_content/api/versions/latest/', 'index.js'), indexContent); - -generateDummyDocs('./_content/docs/'); \ No newline at end of file +fs.writeFileSync(path.join('./_content/docs/latest/', 'index.js'), indexContent);