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 CI workflow with caching and linting #83

Merged
merged 2 commits into from
Jul 5, 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
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

env:
NODE_VERSION: '22'

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ env.NODE_VERSION }}-

- name: Install dependencies
run: npm install

- name: Lint code
run: npm run lint
4 changes: 2 additions & 2 deletions src/lib/scripts/seedData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ function getRandomCoordinate(min: number, max: number): number {
}

function generateRandomWord(): string {
// Source: https://stackoverflow.com/a/8084248
return (Math.random() + 1).toString(36).substring(9);
}

Expand Down Expand Up @@ -55,6 +54,7 @@ function generateAndSaveMoments(count: number, filePath: string): void {
// Remove empty properties from each feature
const simplifiedMoments = {
...moments,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
features: moments.features.map(({ properties, ...rest }) => rest)
};

Expand All @@ -71,7 +71,7 @@ function generateAndSaveDescriptions(count: number, filePath: string): void {
saveToFile(descriptions, filePath);
}

function saveToFile(data: any, filePath: string): void {
function saveToFile<T>(data: T, filePath: string): void {
const dir = dirname(filePath);
if (!existsSync(dir)) {
mkdirSync(dir, { recursive: true });
Expand Down