Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build check #84

Merged
merged 7 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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: Generate docs metadata
run: npm run metadata
- name: Generate dummy docs metadata
run: npm run dummy_docs
- name: Run build
run: npm run build
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 5 additions & 2 deletions scripts/documentationMetadataHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 22 additions & 0 deletions scripts/generateDummyVersions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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, addIndex = true) => {
if (!fs.existsSync(folder)) {
fs.mkdirSync(folder, { recursive: true });
}

addIndex && generateDocumentationMetadata(folder);

};

generateDummyDocs('./_content/api/versions/');
generateDummyDocs('./_content/docs/latest', false);
generateDummyDocs('./_content/docs/');
const indexContent = `
const allDocs = ['latest'];
export default allDocs;
`;
fs.writeFileSync(path.join('./_content/docs/latest/', 'index.js'), indexContent);
Loading