forked from LayerZero-Labs/devtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🪚 CI (non-interactive) mode for create-lz-oapp; User tests (LayerZero…
- Loading branch information
1 parent
694e1c1
commit a18bb0d
Showing
21 changed files
with
474 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"create-lz-oapp": patch | ||
--- | ||
|
||
Add ability run in CI (non-interactive) mode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ node_modules | |
*.yaml | ||
Dockerfile | ||
Makefile | ||
*.bats |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,16 @@ services: | |
healthcheck: | ||
interval: 2s | ||
retries: 10 | ||
test: ["CMD", "wget", "--output-document", "--tries=1", "--no-verbose", "--spider", "http://0.0.0.0:4873/-/ping"] | ||
test: | ||
[ | ||
"CMD", | ||
"wget", | ||
"--output-document", | ||
"--tries=1", | ||
"--no-verbose", | ||
"--spider", | ||
"http://0.0.0.0:4873/-/ping", | ||
] | ||
stop_grace_period: 120s | ||
volumes: | ||
- ./verdaccio.yaml:/verdaccio/conf/config.yaml | ||
|
@@ -40,9 +49,9 @@ services: | |
- npm-registry | ||
# Here we build and publish all the packages locally, | ||
# including any pending changesets. | ||
# | ||
# | ||
# Even though we enabled anonymous publishing in verdaccio, | ||
# we need to specify some sort of an auth token | ||
# we need to specify some sort of an auth token | ||
# since we are trying to publish scoped packages. This can be anything, | ||
# any non-empty string will do | ||
command: | ||
|
@@ -67,13 +76,29 @@ services: | |
depends_on: | ||
publish: | ||
condition: service_completed_successfully | ||
# create-lz-oapp allows us to specify the repository/ref we pull the examples from | ||
# | ||
# In order to test the version on this branch in github actions, | ||
# we'll set these based on the default variables github gives us | ||
# | ||
# 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: | ||
- [email protected]:${GITHUB_REPOSITORY:-LayerZero-Labs/devtools} | ||
- LAYERZERO_EXAMPLES_REPOSITORY_REF=${GITHUB_REF_NAME} | ||
working_dir: /app | ||
command: | ||
- /bin/bash | ||
- -c | ||
- | | ||
pnpm config set registry http://npm-registry:4873/ | ||
./tests-user/create-lz-oapp.sh | ||
volumes: | ||
- ./tests-user:/tests-user | ||
/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 | ||
# otherwise git clone would trigger an interactive prompt asking us to add a server fingerprint | ||
# | ||
# See more here https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints | ||
- ./tests-user/ssh/known_hosts:/root/.ssh/known_hosts | ||
# The testing library and test suites | ||
- ./tests-user:/app/tests-user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import React from "react"; | ||
import type { Config } from "@/types"; | ||
import { Box, Text } from "ink"; | ||
import { | ||
BadGitRefError, | ||
DestinationNotEmptyError, | ||
DownloadError, | ||
MissingGitRefError, | ||
} from "@/utilities/cloning"; | ||
|
||
interface ErrorMessageProps { | ||
config: Config; | ||
error?: unknown; | ||
} | ||
|
||
export const ErrorMessage: React.FC<ErrorMessageProps> = ({ | ||
config, | ||
error, | ||
}) => { | ||
if (error == null) return null; | ||
|
||
switch (true) { | ||
case error instanceof DestinationNotEmptyError: | ||
return ( | ||
<Text color="red"> | ||
Destination directory <Text bold>{config.destination}</Text> is not | ||
empty | ||
</Text> | ||
); | ||
|
||
case error instanceof BadGitRefError: | ||
return ( | ||
<Text color="red"> | ||
The example <Text bold>{config.example.label}</Text> has its | ||
repository URL malformed: ' | ||
<Text bold>{config.example.repository}</Text>' does not look like a | ||
valid repository | ||
</Text> | ||
); | ||
|
||
case error instanceof MissingGitRefError: | ||
return ( | ||
<Text color="red"> | ||
The example <Text bold>{config.example.label}</Text> does not seem to | ||
exist in the repository | ||
</Text> | ||
); | ||
|
||
case error instanceof DownloadError: | ||
return ( | ||
<Box flexDirection="column"> | ||
<Text color="red">There was a problem downloading the example</Text> | ||
<Text>â—‹ Please check your internet connection</Text> | ||
<Text> | ||
â—‹ Please check that the example exists ( | ||
<Text bold>{config.example.repository}</Text>) | ||
</Text> | ||
</Box> | ||
); | ||
|
||
case error instanceof Error: | ||
return <DefaultErrorMessage error={error} />; | ||
|
||
default: | ||
return <DefaultErrorMessage error={String(error)} />; | ||
} | ||
}; | ||
|
||
export const DefaultErrorMessage: React.FC<{ error: Error | string }> = ({ | ||
error, | ||
}) => { | ||
return ( | ||
<Text color="red"> | ||
<Text bold>{String(error)}</Text> | ||
</Text> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.