Skip to content

Commit

Permalink
chore: fix minor issues in tooling and tests (#1231)
Browse files Browse the repository at this point in the history
  • Loading branch information
saikumarrs authored Feb 21, 2024
1 parent 5e533ba commit 4d43918
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 38 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ jobs:
env:
HUSKY: 0
run: |
npm ci
- name: Set up Python
run: scripts/setup-python.sh
npm run setup
- name: Display Python Version
run: |
Expand All @@ -57,9 +54,6 @@ jobs:
run: |
npm run test:ci
- name: Install Python Dependencies
run: pip3 install -r ./scripts/requirements.txt

- name: List Working Directory Files
run: |
echo current directory
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/report-code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ jobs:
cache: 'npm'

- name: Install Dependencies
run: npm ci

- name: Set up Python
run: scripts/setup-python.sh
run: npm run setup

- name: Run Tests
run: npm run test:ci
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ jobs:
cache: 'npm'

- name: Install Dependencies
run: npm ci

- name: Set up Python
run: scripts/setup-python.sh
run: npm run setup

- name: Run Tests
run: npm run test:ci
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ jobs:
- name: Checkout
uses: actions/[email protected]

- uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Setting up python libraries
run: ./scripts/setup-python.sh
- name: Install Dependencies
run: npm run setup:python

# Reference: https://black.readthedocs.io/en/stable/integrations/github_actions.html
- name: Check formatting for Python files
Expand All @@ -39,7 +35,7 @@ jobs:
cache: 'npm'

- name: Install Dependencies
run: npm ci
run: npm run setup:npm

- name: Run Lint Checks
run: |
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@

You need to install Python3.

And then, install Python dependencies:
And then, setup the project dependencies by running below command:

`pip3 install -r ./scripts/requirements.txt`
`npm run setup`

Run below command to deploy integrations definitions config to database:

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"url": "https://github.com/rudderlabs/rudder-config-schema.git"
},
"scripts": {
"setup": "npm ci",
"setup:python": "pip3 install -r ./scripts/requirements.txt",
"setup:npm": "npm ci",
"setup": "npm run setup:npm && npm run setup:python",
"test": "jest --detectOpenHandles --coverage --notify --watchAll=false",
"test:ci": "npm run test -- --silent --expand --maxWorkers=2",
"test:silent": "npm run test -- --silent",
Expand Down Expand Up @@ -82,7 +84,7 @@
},
"lint-staged": {
"*.{json,js,ts,md}": "prettier --write",
"*.{py}": "python3 -m black"
"*.py": "python3 -m black"
},
"config": {
"commitizen": {
Expand Down
1 change: 1 addition & 0 deletions scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
requests
jsonschema
jsondiff
black
8 changes: 0 additions & 8 deletions scripts/setup-python.sh

This file was deleted.

23 changes: 19 additions & 4 deletions test/component_tests/schemaGenerator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ import fs from 'fs';
import path from 'path';
import { execSync } from 'child_process';

function readFile(filePath): string | undefined {
let file;
if (!fs.existsSync(filePath)) {
return file;
}

try {
file = fs.readFileSync(filePath, 'utf8');
} catch (e) {
/* empty */
}

return file;
}

function readSchemaFile(filePath): string | undefined {
let schema;
if (!fs.existsSync(filePath)) {
Expand All @@ -17,8 +32,8 @@ function readSchemaFile(filePath): string | undefined {
return schema;
}

function writeSchemaFile(filePath, schema) {
fs.writeFileSync(filePath, JSON.stringify(schema, null, 2));
function writeFile(filePath, data) {
fs.writeFileSync(filePath, data);
}

describe('Schema Generator', () => {
Expand Down Expand Up @@ -102,7 +117,7 @@ describe('Schema Generator', () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
it.each(testData)('$description', ({ description, destName, expectedSchemaFile }) => {
const schemaFilePath = path.resolve(`${configDir}/destinations/${destName}/schema.json`);
const curSchema = readSchemaFile(schemaFilePath);
const curSchema = readFile(schemaFilePath);

const cmd = `CONFIG_DIR=${configDir} npm run update:schema:destination "${destName}"`;

Expand All @@ -111,7 +126,7 @@ describe('Schema Generator', () => {
const schema = readSchemaFile(schemaFilePath);
// Restore schema file
if (curSchema) {
writeSchemaFile(schemaFilePath, curSchema);
writeFile(schemaFilePath, curSchema);
}

const expectedSchemaData = readSchemaFile(
Expand Down

0 comments on commit 4d43918

Please sign in to comment.