Skip to content

Commit

Permalink
Add CI job (and make it green) (#42)
Browse files Browse the repository at this point in the history
* Add CI job

* Add ci script

* Run format in examples package

* Format docs

* Fix eslint config in langchain

* Add ci command

* Separate unit and integration tests

* Fix ci command

* Make path relative, adjust node version

* Add os matrix

* Set eol to lf

* Do not cache CI command

* Try to fix loadFromHub on windows

* Update CONTRIBUTING for unit/int tests
  • Loading branch information
nfcampos authored Feb 19, 2023
1 parent 70e8a9e commit 8035633
Show file tree
Hide file tree
Showing 72 changed files with 597 additions and 429 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
build:
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
node-version: [16.x, 18.x, 19.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Install dependencies
run: yarn install --immutable
- run: yarn run ci
- run: yarn workspace langchain run test
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
run: yarn install --frozen-lockfile
run: yarn install --immutable
- name: Build website
run: yarn workspace docs build
- name: Setup Pages
Expand Down
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"endOfLine": "lf"
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": "./.github/workflows/deploy.yml"
}
}
18 changes: 10 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ good code into the codebase.
### 🏭Release process

# TODO:

As of now, LangChain has an ad hoc release process: releases are cut with high frequency via by
a developer and published to [npm](https://www.npmjs.com/package/langchain).

Expand All @@ -68,26 +69,27 @@ with if you plan to contribute:
- **[prettier](https://prettier.io/)** - enforcing standard code formatting
- **[jest](https://jestjs.io/)** - testing code
- **[TypeDoc](https://typedoc.org/)** - reference doc generation from
comments
comments
- **[Docusaurus](https://docusaurus.io/)** - static site generation for documentation


Now, you should be able to run the common tasks in the following section.

## ✅Common Tasks

### Testing

Tests should be added within a `tests/` folder alongside the modules they
are testing.

**Unit tests** cover modular logic that does not require calls to outside APIs.

If you add new logic, please add a unit test.
Unit tests should be called `*.test.ts`.

**Integration tests** cover logic that requires making calls to outside APIs (often integration with other services).

If you add support for a new external API, please add a new integration test.

Tests should be added within a `tests/` folder alongside the modules they
are testing.
Integration tests should be called `*.int.test.ts`.

To run tests, run:

Expand All @@ -111,7 +113,7 @@ level of the repo.
Langchain let's user import from multiple subpaths, e.g.

```ts
import { OpenAI } from "langchain/llms"
import { OpenAI } from "langchain/llms";
```

In order to declare a new entrypoint that users can import from, you
Expand All @@ -122,8 +124,8 @@ the following to the `entrypoints` variable:
```ts
const entrypoints = {
// ...
"tools": "agents/tools/index.ts",
}
tools: "agents/tools/index.ts",
};
```

This will make sure the entrypoint is included in the published package,
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Please fill out [this form](https://forms.gle/57d8AmXBYp8PP8tZA) and we'll set u
`yarn add langchain`

```typescript
import { OpenAI } from 'langchain/llms';
import { OpenAI } from "langchain/llms";
```

## 🤔 What is this?
Expand All @@ -32,7 +32,6 @@ The [LangChainHub](https://github.com/hwchase17/langchain-hub) is a central plac

For full documentation of prompts, chains, agents and more, please see [here](https://hwchase17.github.io/langchainjs/docs/overview).


## 💁 Contributing

As an open source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infra, or better documentation.
Expand Down
45 changes: 23 additions & 22 deletions docs/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,47 +19,48 @@ module.exports = {
jest: true,
node: true,
},
parser: '@babel/eslint-parser',
parser: "@babel/eslint-parser",
parserOptions: {
allowImportExportEverywhere: true,
},
extends: ['airbnb', 'prettier'],
plugins: ['react-hooks', 'header'],
extends: ["airbnb", "prettier"],
plugins: ["react-hooks", "header"],
ignorePatterns: ["build", "docs/api", "node_modules"],
rules: {
// Ignore certain webpack alias because it can't be resolved
'import/no-unresolved': [
"import/no-unresolved": [
ERROR,
{ignore: ['^@theme', '^@docusaurus', '^@generated']},
{ ignore: ["^@theme", "^@docusaurus", "^@generated"] },
],
'import/extensions': OFF,
'header/header': [
"import/extensions": OFF,
"header/header": [
ERROR,
'block',
"block",

[
'*',
' * Copyright (c) Meta Platforms, Inc. and affiliates.',
' *',
' * This source code is licensed under the MIT license found in the',
' * LICENSE file in the root directory of this source tree.',
' *',
"*",
" * Copyright (c) Meta Platforms, Inc. and affiliates.",
" *",
" * This source code is licensed under the MIT license found in the",
" * LICENSE file in the root directory of this source tree.",
" *",
// Unfortunately eslint-plugin-header doesn't support optional lines.
// If you want to enforce your website JS files to have @flow or @format,
// modify these lines accordingly.
{
pattern: '.* @format',
pattern: ".* @format",
},
' ',
" ",
],
],
'react/jsx-filename-extension': OFF,
'react-hooks/rules-of-hooks': ERROR,
'react/prop-types': OFF, // PropTypes aren't used much these days.
'react/function-component-definition': [
"react/jsx-filename-extension": OFF,
"react-hooks/rules-of-hooks": ERROR,
"react/prop-types": OFF, // PropTypes aren't used much these days.
"react/function-component-definition": [
WARNING,
{
namedComponents: 'function-declaration',
unnamedComponents: 'arrow-function',
namedComponents: "function-declaration",
unnamedComponents: "arrow-function",
},
],
},
Expand Down
1 change: 1 addition & 0 deletions docs/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
build
.docusaurus
docs/api
9 changes: 0 additions & 9 deletions docs/.prettierrc

This file was deleted.

2 changes: 1 addition & 1 deletion docs/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
*/

module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
presets: [require.resolve("@docusaurus/core/lib/babel/preset")],
};
Loading

0 comments on commit 8035633

Please sign in to comment.