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 gh workflow #1

Merged
merged 9 commits into from
Jun 4, 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
78 changes: 78 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: "Test, Lint & Deploy"
on: [push, pull_request]
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- run: nix flake check
- name: Install direnv with Nix
uses: aldoborrero/direnv-nix-action@v2
with:
use_nix_profile: true
- name: Lint
run: deno task lint
- name: Format
run: deno task format
- name: Test
run: deno task test:coverage
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: cov_profile/html/
- name: Generate docs
run: deno task docs
- name: Archive docs
uses: actions/upload-artifact@v4
with:
name: docs
path: docs/
deploy-npm:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Get tag version
if: startsWith(github.ref, 'refs/tags/')
id: get_tag_version
run: echo TAG_VERSION=${GITHUB_REF/refs\/tags\//} >> $GITHUB_OUTPUT
- name: Install direnv with Nix
uses: aldoborrero/direnv-nix-action@v2
with:
use_nix_profile: true
- name: Build
run: deno task build ${{steps.get_tag_version.outputs.TAG_VERSION}}
- name: Publish
if: startsWith(github.ref, 'refs/tags/')
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
working-directory: ./npm
run: npm publish
deploy-docs:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
steps:
# https://github.com/actions/upload-pages-artifact
- uses: actions/upload-pages-artifact@v2
if: startsWith(github.ref, 'refs/tags/')
with:
path: ./docs
- name: Deploy to GitHub Pages
if: startsWith(github.ref, 'refs/tags/')
id: deployment
# https://github.com/actions/deploy-pages
uses: actions/deploy-pages@v2
2 changes: 2 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore: |
.pre-commit-config.yaml
7 changes: 4 additions & 3 deletions deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
"tasks": {
"build": "deno run -A scripts/build_npm.ts",
"test": "deno test --allow-env=API_KEY --allow-net=api.affinity.co --doc --allow-read=./src/v1/tests/ src/**/tests/",
"test:coverage": "deno task test --coverage=cov_profile && deno coverage cov_profile --html && open cov_profile/html/index.html",
"test:coverage": "deno task test --coverage=cov_profile && deno coverage cov_profile --html",
"watch": "deno task test --no-clear-screen --watch --shuffle --parallel",
"snapshot-update": "deno task test --allow-write=./src/v1/tests/__snapshots__ -- --update",
"format": "deno fmt ; nixfmt *.nix",
"format": "deno fmt ; nixfmt *.nix; yamllint .",
"lint": "deno lint",
"docs": "deno run --allow-read --allow-env --allow-run --allow-write=./docs/ npm:[email protected]",
"generate-v2-client": "rm -rf src/v2/ && deno run --allow-read --allow-run --allow-env --allow-write=openapitools.json,node_modules,/tmp,/var --allow-net='search.maven.org,repo1.maven.org' npm:@openapitools/[email protected] generate",
"update-lockfile": "deno cache --lock-write src/index.ts"
"update-deno-lock": "deno cache --lock-write src/index.ts",
"update-flake-lock": "nix --option commit-lockfile-summary 'chore: update flake.lock' flake update --commit-lock-file"
},
"lint": {
"include": [
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
pre-commit.settings.hooks.denofmt.enable = true;
pre-commit.settings.hooks.denolint.enable = true;
pre-commit.settings.hooks.typos.enable = true;
pre-commit.settings.hooks.yamllint.enable = true;

# NOTE: You can also use `config.pre-commit.devShell`
devShells.default = pkgs.mkShell {
Expand All @@ -42,6 +43,7 @@
# For openapi-generator
# If more dependencies are needed, investigate whether to load https://github.com/OpenAPITools/openapi-generator/blob/master/flake.nix
jdk11
yamllint
];
};
};
Expand Down
4 changes: 2 additions & 2 deletions scripts/build_npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ await emptyDir('./npm')
import packageJson from '../package.json' with { type: 'json' }
import ts from 'typescript'

const { name, description, license, repository, version } = packageJson
const { name, description, license, repository } = packageJson

await copy('src/v1/tests/__snapshots__', 'npm/esm/v1/tests/__snapshots__', {
overwrite: true,
Expand Down Expand Up @@ -42,7 +42,7 @@ await build({
},
package: {
name,
version,
version: Deno.args[0],
description,
license,
repository,
Expand Down
3 changes: 3 additions & 0 deletions src/v1/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ export type WhoAmIResponse = {
}
}

/**
* @module
*/
export class Auth {
/** @hidden */
constructor(private readonly axios: AxiosInstance) {
Expand Down
1 change: 1 addition & 0 deletions src/v1/field_values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export type AllQueryParameters = {
}

/**
* @module
* Field values are displayed in Affinity as the data in the cells of an Affinity spreadsheet.
*
* As an example for how a field value is created:
Expand Down
1 change: 1 addition & 0 deletions src/v1/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export type FieldReference = {
}

/**
* @module
* Fields as a data model represent the "columns" in a spreadsheet. A field can be specific to a given list, or it can be global. List-specific fields appear as a column whenever that list is being viewed while global fields are displayed on all lists.
*
* Let us consider two examples:
Expand Down
3 changes: 3 additions & 0 deletions src/v1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export { ActionType } from './field_value_changes.ts'
export type { Brand, Branded } from './brand.ts'
export { PersonType } from './persons.ts'

/**
* @module
*/
export class Affinity {
protected readonly axios: AxiosInstance

Expand Down
2 changes: 2 additions & 0 deletions src/v1/list_entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ export type CreateListEntryParameters = {
}

/**
* @module
*
* *Notes*: Although list entries correspond to rows in an Affinity spreadsheet, the values associated with the entity are not stored inside the list entry resource.
* If you are trying to update, create, or delete a value in one of the custom columns for this list entry, please refer to the [Field Values](https://api-docs.affinity.co/#field-values) section.
* The list entry API is only used for getting, adding, or removing entities from a list.
Expand Down
8 changes: 5 additions & 3 deletions src/v1/lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,12 @@ export type DropdownOption = {
}

/**
* Represents a field in a list.
*
* Each field object has a unique `id`. It also has a `name`, which determines the name of the field, and `allows_multiple`, which determines whether multiple values can be added to a single cell for that field.
*
* Affinity is extremely flexible and customizable, and a lot of that power comes from our ability to support many different value types for fields. Numbers, dates, and locations are all examples of value types, and you can search, sort, or filter all of them.
*/
/**
* Represents a field in a list.
*/
export type Field =
& {
/**
Expand Down Expand Up @@ -255,6 +254,9 @@ export type GetQuery = {
list_id: number
}

/**
* @module
*/
export class Lists {
/** @hidden */
constructor(private readonly axios: AxiosInstance) {
Expand Down
1 change: 1 addition & 0 deletions src/v1/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ export type OrganizationField = Pick<
>

/**
* @module
* An organization in Affinity represents an external company that your team is in touch with- this could be an organization you're trying to invest in, sell to, or establish a relationship with.
*
* An organization has many people associated with it - these are your team's points of contacts at that organization. Just like people, organizations can be added to multiple lists and can be assigned field values.
Expand Down
3 changes: 3 additions & 0 deletions src/v1/rate_limit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ export type RateLimitResponse = {
}
}

/**
* @module
*/
export class RateLimit {
/** @hidden */
constructor(private readonly axios: AxiosInstance) {
Expand Down