Skip to content

Commit

Permalink
Merge pull request #107 from nossas/fix/typescript-build
Browse files Browse the repository at this point in the history
fix: typescript build after enabling tests in github actions pipeline
  • Loading branch information
vivianedias authored Dec 4, 2023
2 parents 794f595 + ee76da0 commit 4afb6af
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 83 deletions.
51 changes: 37 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,61 @@
name: unit-tests

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
workflow_call:
pull_request:
branches:
- "**"

push:
branches:
- "main"

jobs:
tests:
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [14]
node-version: [18]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
- name: Checkout
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Cache .pnpm-store
uses: actions/cache@v1
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
version: 8
run_install: false

- name: Install pnpm
run: curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm i
run: pnpm install --frozen-lockfile

- name: Check code style
run: pnpm m run lint
run: pnpm run lint

- name: Build packages
run: pnpm m run build

- name: Run tests
run: pnpm m run test

Expand Down
21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,20 @@
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"eslint": "^6.8.0",
"eslint": "^6.0.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-jest": "^23.20.0",
"prettier": "^1.19.1"
},
"scripts": {
"lint": "eslint packages/**/*.ts --fix",
"clean": "rm -rf **/*/dist && rm -rf **/*/tsconfig.tsbuildinfo"
},
"dependencies": {
"prettier": "^1.19.1",
"tsc-watch": "4.2.8",
"tslib": "^2.3.1",
"tslib": "^2.4.0",
"tsutils": "^3.21.0",
"typescript": "3.9.5"
},
"scripts": {
"lint": "eslint packages/**/*.ts",
"lint:fix": "pnpm lint --fix",
"clean": "rm -rf **/*/dist && rm -rf **/*/tsconfig.tsbuildinfo && rm -rf **/*/node_modules && rm -rf ./node_modules"
},
"homepage": "https://github.com/nossas/mapa-do-acolhimento#readme",
"repository": {
"type": "git",
Expand All @@ -31,7 +30,7 @@
"url": "https://github.com/nossas/mapa-do-acolhimento/issues"
},
"engines": {
"pnpm": ">=5",
"node": ">=12"
"pnpm": ">=8",
"node": ">=18"
}
}
1 change: 1 addition & 0 deletions packages/cli-zendesk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"devDependencies": {
"@types/debug": "^4.1.5",
"@types/express": "^4.17.6",
"@types/jest": "^26.0.5",
"@types/node": "^14.0.14",
"@types/signale": "^1.4.1",
"@types/source-map-support": "^0.5.1",
Expand Down
10 changes: 6 additions & 4 deletions packages/cli-zendesk/src/zendesk/Base.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import urljoin from "url-join";
import axios from "axios";
import { Debugger } from "debug";
import { AxiosError } from "axios";

const get = async <T>(url: string, log: Debugger, params?: unknown) => {
const {
ZENDESK_API_URL = "",
ZENDESK_API_TOKEN = "",
ZENDESK_API_USER = ""
ZENDESK_API_USER = "",
} = process.env;
const endpoint = urljoin(ZENDESK_API_URL, url);
try {
return await axios.get<T>(endpoint, {
auth: {
username: ZENDESK_API_USER,
password: ZENDESK_API_TOKEN
password: ZENDESK_API_TOKEN,
},
params
params,
});
} catch (e) {
return log(e.response.data);
const error = e as AxiosError;
return log(error?.response?.data);
}
};

Expand Down
1 change: 0 additions & 1 deletion packages/cli-zendesk/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
"outDir": "dist",
"rootDir": "src"
},
"include": ["src/**/*", "__tests__/**/*"]
}
11 changes: 6 additions & 5 deletions packages/components/src/lib/mautic/createOrUpdateContact.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios from "axios";
import axios, { AxiosError } from "axios";
import { getToken } from "../../utils";
import { Contact, FullContact } from "../../types";
import logger from "./childLogger";
Expand All @@ -15,14 +15,14 @@ export default async (
const {
MAUTIC_API_URL,
MAUTIC_USERNAME = "",
MAUTIC_PASSWORD = ""
MAUTIC_PASSWORD = "",
} = process.env;

const config = {
headers: {
Authorization: "Basic " + getToken(MAUTIC_USERNAME, MAUTIC_PASSWORD),
"Content-Type": "application/json"
}
"Content-Type": "application/json",
},
};

try {
Expand All @@ -34,7 +34,8 @@ export default async (
log.info("Successfully edited contact");
return res && res.data;
} catch (e) {
log.error(e.response.data.errors);
const error = e as AxiosError;
log.error(error?.response?.data.errors);
return undefined;
}
};
16 changes: 10 additions & 6 deletions packages/components/src/lib/mautic/findUserByEmail.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios from "axios";
import axios, { AxiosError } from "axios";
import { getToken } from "../../utils";
import { ContactSearchRes } from "../../types";
import logger from "./childLogger";
Expand All @@ -12,24 +12,28 @@ export default async (email: string): Promise<ContactSearchRes | undefined> => {
const {
MAUTIC_API_URL,
MAUTIC_USERNAME = "",
MAUTIC_PASSWORD = ""
MAUTIC_PASSWORD = "",
} = process.env;

const config = {
headers: {
Authorization: "Basic " + getToken(MAUTIC_USERNAME, MAUTIC_PASSWORD)
Authorization: "Basic " + getToken(MAUTIC_USERNAME, MAUTIC_PASSWORD),
},
params: {
search: `email:${email}`
}
search: `email:${email}`,
},
};

try {
const data = await axios.get(MAUTIC_API_URL + "/contacts", config);
log.info("Successfully returned a contact");
return data && data.data;
} catch (e) {
log.error(`${e.response.status}: ${e.response.statusText} %o`, e.config);
const error = e as AxiosError;
log.error(
`${error?.response?.status}: ${error?.response?.statusText} %o`,
error?.config
);
return undefined;
}
};
1 change: 1 addition & 0 deletions packages/webhooks-mautic-zendesk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"devDependencies": {
"@types/debug": "^4.1.7",
"@types/express": "^4.17.13",
"@types/jest": "26.0.5",
"@types/node": "^14.17.19",
"@types/pino": "^6.3.11",
"@types/source-map-support": "^0.5.4",
Expand Down
7 changes: 4 additions & 3 deletions packages/webhooks-solidarity-count/src/Router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ const Router = (apm): Express.Express =>
});
const response = await App(id, apm);
return res.status(200).json(response);
} catch (e: any) {
log.error(e.msg);
} catch (e) {
const error = e as { msg: string, status: number }
log.error(error.msg);
// apm.captureError(new Error(e.msg));
return res.status(e.status).json(e.msg);
return res.status(error.status).json(error.msg);
}
});

Expand Down
4 changes: 2 additions & 2 deletions packages/webhooks-solidarity-count/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ try {
Router(apm).listen(Number(PORT), "0.0.0.0", () => {
log.info(`Server listen on PORT ${PORT}`);
});
} catch (e: any) {
} catch (e) {
log.error(e);
apm.captureError(e);
apm.captureError(e as string);
}
Loading

0 comments on commit 4afb6af

Please sign in to comment.