Skip to content

Commit

Permalink
Merge pull request #534 from Pinelab-studio/fix/linting-in-ci
Browse files Browse the repository at this point in the history
Fix/linting in ci
  • Loading branch information
martijnvdbrug authored Nov 12, 2024
2 parents 24b8850 + b132f69 commit fddf1c4
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 58 deletions.
60 changes: 19 additions & 41 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Test packages
on: ['pull_request']

jobs:
lint:
name: Prettier formatting and linting check
format:
name: Prettier formatting
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -18,50 +18,27 @@ jobs:
run: yarn
- name: Is formatted
run: yarn prettier:check
collect_dirs:
name: Collect package names
runs-on: ubuntu-latest
outputs:
dirs: ${{ steps.dirs.outputs.dirs }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- id: dirs
# This command will list all directories in the packages directory
run: echo "dirs=$(ls -d packages/*/ | jq --raw-input --slurp --compact-output 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT}
test:
needs: collect_dirs
name: ${{ matrix.package }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash
strategy:
matrix:
package:
[
'vendure-plugin-accept-blue',
'vendure-plugin-admin-social-auth',
'vendure-plugin-admin-ui-helpers',
'vendure-plugin-anonymized-order',
'vendure-plugin-campaign-tracker',
'vendure-plugin-coinbase',
'vendure-plugin-customer-managed-groups',
'vendure-plugin-dutch-postalcode',
'vendure-plugin-e-boekhouden',
'vendure-plugin-facet-suggestions',
'vendure-plugin-goedgepickt',
'vendure-plugin-google-cloud-tasks',
'vendure-plugin-google-storage-assets',
'vendure-plugin-invoices',
'vendure-plugin-klaviyo',
'vendure-plugin-limited-products',
'vendure-plugin-metrics',
'vendure-plugin-modify-customer-orders',
'vendure-plugin-multiserver-db-sessioncache',
'vendure-plugin-myparcel',
'vendure-plugin-order-export',
'vendure-plugin-picqer',
'vendure-plugin-payment-extensions',
'vendure-plugin-popularity-scores',
'vendure-plugin-primary-collection',
'vendure-plugin-public-customer-groups',
'vendure-plugin-sendcloud',
'vendure-plugin-shipmate',
'vendure-plugin-shipping-extensions',
'vendure-plugin-stock-monitoring',
'vendure-plugin-stripe-subscription',
'vendure-plugin-variant-bulk-update',
'vendure-plugin-webhook',
]
package: ${{ fromJson(needs.collect_dirs.outputs.dirs) }}
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -71,9 +48,10 @@ jobs:
- name: Install dependencies with Yarn workspaces
run: yarn
- name: Build
run: cd packages/${{ matrix.package }} && yarn build
run: cd ${{ matrix.package }} && yarn build
- name: Lint
run: cd ${{ matrix.package }} && yarn lint
- name: Test
# TEST_ADMIN_UI=true enables Admin UI compilation in tests
run: |
cd packages/${{ matrix.package }}
cd ${{ matrix.package }}
TEST_ADMIN_UI=true yarn test
1 change: 1 addition & 0 deletions eslint-base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default tseslint.config(
'node_modules',
'**/*/dev-server.ts',
'**/test/**',
'**/src/ui/**',
'**/generated/graphql.ts',
],
}
Expand Down
5 changes: 4 additions & 1 deletion packages/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"private": true,
"scripts": {
"generate": "graphql-codegen --config codegen.yml",
"start": "ts-node ./src/dev-server.ts"
"start": "ts-node ./src/dev-server.ts",
"build": "echo 'Not meant to be built'",
"lint": "echo 'Not meant to be linted'",
"test": "echo 'No test implemented'"
}
}
7 changes: 6 additions & 1 deletion packages/util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
"version": "1.0.2",
"main": "index.ts",
"license": "MIT",
"private": true
"private": true,
"scripts": {
"build": "echo 'Not meant to be built'",
"lint": "echo 'Not meant to be linted'",
"test": "echo 'No test implemented'"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
isOlderThan,
validateAttributions,
} from './campaign-util';
import { Attribution } from './attribution-models';

const attributionModel = {
attributeTo: vi.fn(),
Expand Down
12 changes: 8 additions & 4 deletions packages/vendure-plugin-invoices/src/services/invoice.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
} from '@vendure/core';
import { Response } from 'express';
import { createReadStream, ReadStream } from 'fs';
import fs from 'fs/promises';
import Handlebars from 'handlebars';
import {
Invoice,
Expand Down Expand Up @@ -565,22 +564,27 @@ export class InvoiceService implements OnModuleInit, OnApplicationBootstrap {
});
const page = await browser.newPage();
await page.setContent(compiledHtml);
const pdf = await page.pdf({
await page.pdf({
path: tmpFilePath,
format: 'A4',
margin: { bottom: 100, top: 100, left: 50, right: 50 },
});
} catch (e) {
// Warning, because this will be retried, or is returned to the user
Logger.warn(
`Failed to generate invoice: ${JSON.stringify((e as any)?.message)}`,
`Failed to generate invoice: ${JSON.stringify((e as Error)?.message)}`,
loggerCtx
);
throw e;
} finally {
if (browser) {
// Prevent memory leaks
browser.close();
browser.close().catch((e: Error) => {
Logger.error(
`Failed to close puppeteer browser: ${e?.message}`,
loggerCtx
);
});
}
}
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,24 @@ export type ExportedPrimaryCollectionData = {
primaryCollectionId: ID;
};

type ProductPrimaryCollectionPartial = {
product_id: number;
primaryCollection_id: number;
};

export async function exportPrimaryCollections(queryRunner: QueryRunner) {
try {
const productRepo = queryRunner.manager.getRepository(Product);
const allProducts = (await productRepo
const allProducts = await productRepo
.createQueryBuilder('product')
.innerJoin(
Collection,
'primaryCollection',
'primaryCollection.id = product.customFieldsPrimarycollectionId'
)
.select(['product.id', 'primaryCollection.id'])
.getRawMany()) as ProductPrimaryCollectionPartial[];
.getRawMany();
const data: ExportedPrimaryCollectionData[] = [];
for (const product of allProducts) {
data.push({
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
productId: product.product_id,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
primaryCollectionId: product.primaryCollection_id,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,13 @@ export const distanceBasedShippingCalculator = new ShippingCalculator({
taxRate,
metadata: { shippingAddressGeoLocation, storeGeoLocation },
};
} catch (e: any) {
} catch (e) {
//eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
Logger.error(
//eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
`Failed to calculate shipping for ${method.name}: ${e.message}`,
`Failed to calculate shipping for ${method.name}: ${
(e as Error)?.message
}`,
loggerCtx
);
return minimumPrice;
Expand Down
3 changes: 2 additions & 1 deletion packages/vendure-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
],
"scripts": {
"build": "rimraf dist && tsc",
"test": "vitest run"
"test": "vitest run",
"lint": "echo 'No linting configured'"
},
"dependencies": {
"prompt-confirm": "^2.0.4"
Expand Down

0 comments on commit fddf1c4

Please sign in to comment.