Skip to content

Commit

Permalink
Add template-e2e-rest check (#78)
Browse files Browse the repository at this point in the history
* Add template-e2e-rest CI job
* Minor fixes in api-config handling
* Change default location of api-config.json
  • Loading branch information
dzikowski authored May 15, 2024
1 parent 6863b14 commit b16186f
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 9 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/test-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,49 @@ jobs:
fi
npm run network:prune --prefix ./project-test
template-e2e-rest:
name: Chaincode template E2E (REST API)
runs-on: ubuntu-22.04
needs: [ci]
env:
GALA_CLIENT_DEV_MODE: "false"
CURATORORG_OPS_API_URL: "http://localhost:8801"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install tools
run: |
sudo apt-get update
sudo apt-get install -y jq
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod a+x /usr/local/bin/yq
git --version
node --version
npm --version
jq --version
yq --version
bash --version
docker version
docker-compose version
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install local CLI
run: .github/scripts/install-local-cli.sh
- name: Create test project
run: galachain init ./project-test
- name: Install dependencies
run: |
(cd ./project-test && ../npm-pack-and-replace.sh --skipConfirmation)
npm i --prefix ./project-test
- name: Remove nvm file to avoid Fablo calling it and raising nvm issue with npm_config_prefix env
run: rm ~/.nvm/nvm.sh
- name: Run network in non-watch mode
run: npm run network:up --prefix ./project-test
- name: Run E2E tests
run: npm run test:e2e --prefix ./project-test

template-image-check:
name: Chaincode template image check
needs: [ci]
Expand Down
12 changes: 6 additions & 6 deletions chain-cli/chaincode-template/api-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
"asLocalHost": true,
"contracts": [
{
"pathFragment": "apple",
"pathFragment": "apple-contract",
"chaincodeName": "basic-product",
"contractName": "AppleContract"
},
{
"pathFragment": "public-key-contract",
"pathFragment": "gala-chain-token",
"chaincodeName": "basic-product",
"contractName": "PublicKeyContract"
"contractName": "GalaChainToken"
},
{
"pathFragment": "token-contract",
"pathFragment": "public-key-contract",
"chaincodeName": "basic-product",
"contractName": "GalaChainToken"
"contractName": "PublicKeyContract"
}
]
}
]
}
}
4 changes: 2 additions & 2 deletions chain-cli/src/commands/network-up/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ export default class NetworkUp extends BaseCommand<typeof NetworkUp> {
if (flags.contracts) {
// This feature supports only a single channel
console.log("Overwriting api-config.json with contracts: " + flags.contracts);
overwriteApiConfig(flags.contracts, flags.channel[0], flags.chaincodeName[0]);
await overwriteApiConfig(flags.contracts, flags.channel[0], flags.chaincodeName[0]);
}

const fabloRoot = path.resolve(flags.fabloRoot);

const localhostName = process.env.LOCALHOST_NAME ?? "localhost";
console.log("Network root directory:", fabloRoot);

await copyNetworkScriptsTo(fabloRoot);
copyNetworkScriptsTo(fabloRoot);

const singleArgs = reduce(flags).map((a) => ({
...a,
Expand Down
3 changes: 2 additions & 1 deletion chain-test/src/e2e/ContractTestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export function networkRoot() {
}

function defaultOpsApiConfigPath() {
return path.resolve(networkRoot(), "api-config.json");
// by default project root is a parent of network root
return path.resolve(networkRoot(), "..", "api-config.json");
}

function defaultConnectionProfilePath(orgKey: "curator" | "users" | "partner"): string {
Expand Down

0 comments on commit b16186f

Please sign in to comment.