Skip to content

Commit

Permalink
🪚 Enable user tests for create-lz-oapp (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista authored Jan 31, 2024
1 parent 68e5592 commit 7aaf750
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-keys-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-lz-oapp": patch
---

Update repository URL
6 changes: 6 additions & 0 deletions .changeset/plenty-cars-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@layerzerolabs/oapp-example": patch
"@layerzerolabs/oft-example": patch
---

Fix compile & tests scripts for npm
5 changes: 4 additions & 1 deletion docker-compose.registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ services:
# If these are not provided, for example if running on a local machine,
# we'll default them to our repository and and empty ref
environment:
- LAYERZERO_EXAMPLES_REPOSITORY_URL=git@github.com:${GITHUB_REPOSITORY:-LayerZero-Labs/devtools}
- LAYERZERO_EXAMPLES_REPOSITORY_URL=https://github.com/${GITHUB_REPOSITORY:-LayerZero-Labs/devtools}.git
- LAYERZERO_EXAMPLES_REPOSITORY_REF=${GITHUB_REF_NAME}
working_dir: /app
command:
Expand All @@ -93,6 +93,9 @@ services:
- |
pnpm config set registry http://npm-registry:4873/
echo "create-lz-oapp:repository $LAYERZERO_EXAMPLES_REPOSITORY_URL"
echo "create-lz-oapp:ref $LAYERZERO_EXAMPLES_REPOSITORY_REF"
/app/tests-user/lib/bats-core/bin/bats --verbose-run --recursive ./tests-user/tests
volumes:
# If we want to clone from github.com, we'll need its public keys added to our SSH config
Expand Down
7 changes: 6 additions & 1 deletion examples/oapp/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ artifacts
cache
dist
node_modules
out
out
*.log
*.sol
*.yaml
*.lock
package-lock.json
7 changes: 6 additions & 1 deletion examples/oapp/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ artifacts/
cache/
dist/
node_modules/
out/
out/
*.log
*ignore
*.yaml
*.lock
package-lock.json
6 changes: 3 additions & 3 deletions examples/oapp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ pnpm compile:hardhat
Or adjust the `package.json` to for example remove `forge` build:

```diff
- "compile": "$npm_execpath compile:forge && $npm_execpath compile:hardhat",
- "compile": "$npm_execpath run compile:forge && $npm_execpath run compile:hardhat",
- "compile:forge": "forge build",
- "compile:hardhat": "$npm_execpath hardhat compile",
+ "compile": "$npm_execpath hardhat compile"
- "compile:hardhat": "hardhat compile",
+ "compile": "hardhat compile"
```

#### Running tests
Expand Down
14 changes: 7 additions & 7 deletions examples/oapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
"license": "MIT",
"scripts": {
"clean": "rm -rf artifacts cache out",
"compile": "$npm_execpath compile:forge && $npm_execpath compile:hardhat",
"compile": "$npm_execpath run compile:forge && $npm_execpath run compile:hardhat",
"compile:forge": "forge build",
"compile:hardhat": "$npm_execpath hardhat compile",
"lint": "$npm_execpath lint:js && $npm_execpath lint:sol",
"lint:fix": "$npm_execpath prettier --write . && solhint 'contracts/**/*.sol' --fix --noPrompt",
"lint:js": "$npm_execpath eslint '**/*.js' && $npm_execpath prettier --check .",
"compile:hardhat": "hardhat compile",
"lint": "$npm_execpath run lint:js && $npm_execpath run lint:sol",
"lint:fix": "eslint --fix '**/*.js' && prettier --write . && solhint 'contracts/**/*.sol' --fix --noPrompt",
"lint:js": "eslint '**/*.js' && prettier --check .",
"lint:sol": "solhint 'contracts/**/*.sol'",
"test": "$npm_execpath test:forge && $npm_execpath test:hardhat",
"test": "$npm_execpath run test:forge && $npm_execpath run test:hardhat",
"test:forge": "forge test",
"test:hardhat": "$npm_execpath hardhat test"
"test:hardhat": "hardhat test"
},
"devDependencies": {
"@babel/core": "^7.23.7",
Expand Down
7 changes: 6 additions & 1 deletion examples/oft/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ artifacts
cache
dist
node_modules
out
out
*.log
*.sol
*.yaml
*.lock
package-lock.json
7 changes: 6 additions & 1 deletion examples/oft/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ artifacts/
cache/
dist/
node_modules/
out/
out/
*.log
*ignore
*.yaml
*.lock
package-lock.json
6 changes: 3 additions & 3 deletions examples/oft/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ pnpm compile:hardhat
Or adjust the `package.json` to for example remove `forge` build:

```diff
- "compile": "$npm_execpath compile:forge && $npm_execpath compile:hardhat",
- "compile": "$npm_execpath run compile:forge && $npm_execpath run compile:hardhat",
- "compile:forge": "forge build",
- "compile:hardhat": "$npm_execpath hardhat compile",
+ "compile": "$npm_execpath hardhat compile"
- "compile:hardhat": "hardhat compile",
+ "compile": "hardhat compile"
```

#### Running tests
Expand Down
15 changes: 8 additions & 7 deletions examples/oft/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
"private": true,
"license": "MIT",
"scripts": {
"compile": "$npm_execpath compile:forge && $npm_execpath compile:hardhat",
"clean": "rm -rf artifacts cache out",
"compile": "$npm_execpath run compile:forge && $npm_execpath run compile:hardhat",
"compile:forge": "forge build",
"compile:hardhat": "$npm_execpath hardhat compile",
"lint": "$npm_execpath lint:js && $npm_execpath lint:sol",
"lint:fix": "$npm_execpath prettier --write . && solhint 'contracts/**/*.sol' --fix --noPrompt",
"lint:js": "$npm_execpath eslint '**/*.js' && $npm_execpath prettier --check .",
"compile:hardhat": "hardhat compile",
"lint": "$npm_execpath run lint:js && $npm_execpath run lint:sol",
"lint:fix": "eslint --fix '**/*.js' && prettier --write . && solhint 'contracts/**/*.sol' --fix --noPrompt",
"lint:js": "eslint '**/*.js' && prettier --check .",
"lint:sol": "solhint 'contracts/**/*.sol'",
"test": "$npm_execpath test:forge && $npm_execpath test:hardhat",
"test": "$npm_execpath run test:forge && $npm_execpath run test:hardhat",
"test:forge": "forge test",
"test:hardhat": "$npm_execpath hardhat test"
"test:hardhat": "hardhat test"
},
"devDependencies": {
"@babel/core": "^7.23.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-lz-oapp/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { isPackageManagerAvailable } from './utilities/installation'
* To enable example development in a custom repository
* we open the repository URL field to be taken from the environment
*/
const repository = process.env['LAYERZERO_EXAMPLES_REPOSITORY_URL'] || 'git@github.com:LayerZero-Labs/devtools'
const repository = process.env['LAYERZERO_EXAMPLES_REPOSITORY_URL'] || 'https://github.com/LayerZero-Labs/devtools.git'

Check warning on line 8 in packages/create-lz-oapp/src/config.ts

View workflow job for this annotation

GitHub Actions / Check code / Build & Lint

LAYERZERO_EXAMPLES_REPOSITORY_URL is not listed as a dependency in root turbo.json

/**
* To enable example development in a custom branch,
Expand Down
2 changes: 1 addition & 1 deletion packages/create-lz-oapp/src/utilities/cloning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const cloneExample = async ({ example, destination }: Config) => {
}
}

throw new CloningError()
throw new CloningError(`Unknown error: ${error}`)
}
}

Expand Down
19 changes: 12 additions & 7 deletions tests-user/tests/create-lz-oapp.bats
Original file line number Diff line number Diff line change
Expand Up @@ -83,62 +83,67 @@ teardown() {
}

@test "should work with pnpm & oapp example in CI mode" {
skip
local DESTINATION="$PROJECTS_DIRECTORY/pnpm-oapp"

npx --yes create-lz-oapp --ci --example oapp --destination $DESTINATION --package-manager pnpm
assert_success
cd "$DESTINATION"
pnpm compile
pnpm test
pnpm lint
pnpm lint:fix
}

@test "should work with pnpm & oft example in CI mode" {
skip
local DESTINATION="$PROJECTS_DIRECTORY/pnpm-oft"

npx --yes create-lz-oapp --ci --example oft --destination $DESTINATION --package-manager pnpm
cd "$DESTINATION"
pnpm compile
pnpm test
pnpm lint
pnpm lint:fix
}

@test "should work with yarn & oapp example in CI mode" {
skip
local DESTINATION="$PROJECTS_DIRECTORY/yarn-oapp"

npx --yes create-lz-oapp --ci --example oapp --destination $DESTINATION --package-manager yarn
cd "$DESTINATION"
yarn compile
yarn test
yarn lint
yarn lint:fix
}

@test "should work with yarn & oft example in CI mode" {
skip
local DESTINATION="$PROJECTS_DIRECTORY/yarn-oft"

npx --yes create-lz-oapp --ci --example oft --destination $DESTINATION --package-manager yarn
cd "$DESTINATION"
yarn compile
yarn test
yarn lint
yarn lint:fix
}

@test "should work with npm & oapp example in CI mode" {
skip
local DESTINATION="$PROJECTS_DIRECTORY/npm-oapp"

npx --yes create-lz-oapp --ci --example oapp --destination $DESTINATION --package-manager npm
cd "$DESTINATION"
npm run compile
npm run test
npm run lint
npm run lint:fix
}

@test "should work with npm & oft example in CI mode" {
skip
local DESTINATION="$PROJECTS_DIRECTORY/npm-oft"

npx --yes create-lz-oapp --ci --example oft --destination $DESTINATION --package-manager npm
cd "$DESTINATION"
npm run compile
npm run test
npm run lint
npm run lint:fix
}

0 comments on commit 7aaf750

Please sign in to comment.