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

chore: Add GitHub actions #158

Merged
merged 4 commits into from
Aug 15, 2023
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
44 changes: 0 additions & 44 deletions .circleci/config.yml

This file was deleted.

175 changes: 175 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
name: rsnd
on:
push:
branches:
- main
pull_request:
jobs:
lint:
runs-on: buildjet-4vcpu-ubuntu-2204
container:
image: node:18
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache node modules
id: npm-cache
uses: buildjet/cache@v3
with:
path: ~/.node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache yarn cache
id: yarn-cache
uses: buildjet/cache@v3
with:
path: ~/.cache/yarn
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install packages
if: steps.npm-cache.outputs.cache-hit != 'true'
run: yarn
- name: Run Lint
run: yarn lint
format:
runs-on: buildjet-4vcpu-ubuntu-2204
container:
image: node:16
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache node modules
id: npm-cache
uses: buildjet/cache@v3
with:
path: ~/.node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache yarn cache
id: yarn-cache
uses: buildjet/cache@v3
with:
path: ~/.cache/yarn
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install packages
if: steps.npm-cache.outputs.cache-hit != 'true'
run: yarn
- name: Run Format Check
run: yarn format:check
# test:
# runs-on: buildjet-4vcpu-ubuntu-2204
# container:
# image: node:16
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Cache node modules
# id: npm-cache
# uses: buildjet/cache@v3
# with:
# path: ~/.node_modules
# key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-node-
# - name: Cache yarn cache
# id: yarn-cache
# uses: buildjet/cache@v3
# with:
# path: ~/.cache/yarn
# key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-yarn-
# - name: Install packages
# if: steps.npm-cache.outputs.cache-hit != 'true'
# run: yarn
# - name: Run Tests
# run: yarn test
build:
runs-on: buildjet-4vcpu-ubuntu-2204
container:
image: node:16
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache node modules
id: npm-cache
uses: buildjet/cache@v3
with:
path: ~/.node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache yarn cache
id: yarn-cache
uses: buildjet/cache@v3
with:
path: ~/.cache/yarn
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install packages
if: steps.npm-cache.outputs.cache-hit != 'true'
run: yarn
- name: Run Build
run: yarn build
dependencies:
runs-on: buildjet-4vcpu-ubuntu-2204
container:
image: node:16
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache node modules
id: npm-cache
uses: buildjet/cache@v3
with:
path: ~/.node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache yarn cache
id: yarn-cache
uses: buildjet/cache@v3
with:
path: ~/.cache/yarn
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install packages
if: steps.npm-cache.outputs.cache-hit != 'true'
run: yarn
- name: Check for pinned dependencies
run: |
node -e '
const fs = require("fs");
const pkg = JSON.parse(fs.readFileSync("package.json", "utf8"));
const errors = [];

function isPinned(version) {
return /^\d+\.\d+\.\d+$|^[a-z]+:[a-z]+@\d+$/.test(version);
}

for (const [dep, version] of Object.entries(pkg.dependencies || {})) {
if (!isPinned(version)) {
errors.push(`Dependency "${dep}" is not pinned: "${version}"`);
}
}

for (const [dep, version] of Object.entries(pkg.devDependencies || {})) {
if (!isPinned(version)) {
errors.push(`Dev dependency "${dep}" is not pinned: "${version}"`);
}
}

if (errors.length > 0) {
console.error(`\n${errors.join("\n")}\n`);
process.exit(1);
} else {
console.log("All dependencies are pinned.");
}
'
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
},
"scripts": {
"build": "tsc -p .",
"lint": "eslint --fix --ext .ts ./src",
"test": "jest",
"test:watch": "jest --watch",
"prettier": "prettier \"src/**/*.{js,ts,tsx}\" --check",
"format": "prettier \"src/**/*.{js,ts,tsx}\" --write",
"lint": "eslint --fix --ext .ts ./src",
"format:check": "prettier --check \"**/*.{ts,tsx}\"",
"format": "prettier --write .",
"prepublishOnly": "yarn run build"
},
"repository": {
Expand Down
6 changes: 3 additions & 3 deletions src/emails/interfaces/create-email-options.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ interface CreateEmailBaseOptions {
react?: React.ReactElement | React.ReactNode | null;
/**
* The HTML version of the message.
*
*
* @link https://resend.com/api-reference/emails/send-email#body-parameters
*/
html?: string;
/**
* The plain text version of the message.
*
*
* @link https://resend.com/api-reference/emails/send-email#body-parameters
*/
text?: string;
Expand All @@ -71,7 +71,7 @@ interface CreateEmailBaseOptions {
tags?: Tag[];
/**
* Recipient email address. For multiple addresses, send as an array of strings. Max 50.
*
*
* @link https://resend.com/api-reference/emails/send-email#body-parameters
*/
to: string | string[];
Expand Down
6 changes: 5 additions & 1 deletion src/resend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ export class Resend {
return await response.json();
}

async post<T>(path: string, entity?: any, options: PostOptions = {}): Promise<T> {
async post<T>(
path: string,
entity?: any,
options: PostOptions = {},
): Promise<T> {
const requestOptions = {
method: 'POST',
headers: this.headers,
Expand Down