Skip to content

Commit

Permalink
Merge pull request #604 from golemfactory/fix-examples
Browse files Browse the repository at this point in the history
test(examples) changed examples to run on testnet
  • Loading branch information
mgordel authored Sep 30, 2023
2 parents 4d68c3f + 1a16825 commit e1d357f
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/cypress-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
cypress-tests:
runs-on: goth2
runs-on: [goth2, ubuntu-22.10]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -34,6 +34,7 @@ jobs:
npm run build
- name: Configure python
continue-on-error: true
uses: actions/setup-python@v4
with:
python-version: "3.10"
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/examples-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
run: echo "::set-output name=matrix::{\"include\":[{\"branch\":\"master\"}]}"

goth-tests:
runs-on: goth2
runs-on: [goth2, ubuntu-22.10]
needs: prepare-matrix-master-only
strategy:
matrix: ${{ fromJson(needs.prepare-matrix-master-only.outputs.matrix-json) }}
Expand All @@ -46,6 +46,7 @@ jobs:
npm install ts-node
- name: Configure python
continue-on-error: true
uses: actions/setup-python@v4
with:
python-version: "3.10"
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/goth-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
run: echo "::set-output name=matrix::{\"include\":[{\"branch\":\"master\"}]}"

goth-tests:
runs-on: goth2
runs-on: [goth2, ubuntu-22.10]
needs: prepare-matrix-master-only
strategy:
matrix: ${{ fromJson(needs.prepare-matrix-master-only.outputs.matrix-json) }}
Expand All @@ -44,6 +44,7 @@ jobs:
npm run build
- name: Configure python
continue-on-error: true
uses: actions/setup-python@v4
with:
python-version: "3.10"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const myFilter = async (proposal) => {
else {
costData.shift();
let averageProposedCost = costData.reduce((part, x) => part + x, 0) / 10;
if (proposedCost <= averageProposedCost) decision = true;
if (proposedCost <= 1.2 * averageProposedCost) decision = true;
if (decision) {
console.log(proposedCost, averageProposedCost);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import { TaskExecutor, ProposalFilters } from "@golem-sdk/golem-js";
* which only allows offers from a provider whose ID is in the array
*/

const whiteListIds = ["0x3fc1d65ddc5258dc8807df30a29f71028e965e1b", "0x4506550de84d207f3ab90add6336f68119015836"];
const whiteListIds = [
"0x3a21c608925ddbc745afab6375d1f5e77283538e",
"0xd79f83f1108d1fcbe0cf57e13b452305eb38a325",
"0x677c5476f3b0e1f03d5c3abd2e2e2231e36fddde",
"0x06c03165aaa676680b9d02c1f3ee846c3806fec7",
"0x17ec8597ff92c3f44523bdc65bf0f1be632917ff", // goth provider-1:
"0x63fc2ad3d021a4d7e64323529a55a9442c444da0", // goth provider-2:
];
console.log("Will accept only proposals from:");
for (let i = 0; i < whiteListIds.length; i++) {
console.log(whiteListIds[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TaskExecutor } from "@golem-sdk/golem-js";
(async () => {
const executor = await TaskExecutor.create({
package: "golem/alpine:latest",
yagnaOptions: { appKey: "try_golem" },
yagnaOptions: { apiKey: "try_golem" },
});

const result = await executor.run(async (ctx) => (await ctx.run("node -v")).stdout);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"@typescript-eslint/parser": "^6.0.0",
"buffer": "^6.0.3",
"cypress": "13.2.0",
"eslint": "~8.49.0",
"eslint": "~8.50.0",
"eslint-config-prettier": "^9.0.0",
"express": "^4.18.2",
"husky": "^8.0.3",
Expand Down
22 changes: 17 additions & 5 deletions tests/examples/examples.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
[
{ "cmd": "node", "path": "examples/docs-examples/examples/composing-tasks/batch-end.mjs" },
{ "cmd": "node", "path": "examples/docs-examples/examples/composing-tasks/batch-endstream-chunks.mjs" },
{ "cmd": "node", "path": "examples/docs-examples/examples/composing-tasks/batch-endstream-forawait.mjs" },
{ "cmd": "node", "path": "examples/docs-examples/examples/composing-tasks/batch-end.mjs", "noGoth": true },
{
"cmd": "node",
"path": "examples/docs-examples/examples/composing-tasks/batch-endstream-chunks.mjs",
"noGoth": true
},
{
"cmd": "node",
"path": "examples/docs-examples/examples/composing-tasks/batch-endstream-forawait.mjs",
"noGoth": true
},
{ "cmd": "node", "path": "examples/docs-examples/examples/composing-tasks/multiple-run-prosaic.mjs" },
{ "cmd": "node", "path": "examples/docs-examples/examples/composing-tasks/single-command.mjs" },
{ "cmd": "node", "path": "examples/docs-examples/examples/composing-tasks/single-command.cjs" },
Expand All @@ -15,7 +23,7 @@

{ "cmd": "node", "path": "examples/docs-examples/examples/selecting-providers/custom-price.mjs", "noGoth": true },
{ "cmd": "node", "path": "examples/docs-examples/examples/selecting-providers/demand.mjs" },
{ "cmd": "node", "path": "examples/docs-examples/examples/selecting-providers/whitelist.mjs", "noGoth": true },
{ "cmd": "node", "path": "examples/docs-examples/examples/selecting-providers/whitelist.mjs" },

{ "cmd": "node", "path": "examples/docs-examples/examples/sending-data/downloading-file.mjs" },
{ "cmd": "node", "path": "examples/docs-examples/examples/sending-data/uploading-file.mjs" },
Expand All @@ -33,7 +41,11 @@
{ "cmd": "node", "path": "examples/docs-examples/examples/working-with-images/tag.mjs" },

{ "cmd": "node", "path": "examples/docs-examples/examples/working-with-results/multi-command-end.mjs" },
{ "cmd": "node", "path": "examples/docs-examples/examples/working-with-results/multi-command-endstream.mjs" },
{
"cmd": "node",
"path": "examples/docs-examples/examples/working-with-results/multi-command-endstream.mjs",
"noGoth": true
},
{
"cmd": "node",
"path": "examples/docs-examples/examples/working-with-results/multi-command-fail.mjs",
Expand Down
2 changes: 1 addition & 1 deletion tests/examples/examples.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Example = {
skip?: boolean;
};

async function test(cmd: string, path: string, args: string[] = [], timeout = 120) {
async function test(cmd: string, path: string, args: string[] = [], timeout = 180) {
const file = basename(path);
const cwd = dirname(path);
const spawnedExample = spawn(cmd, [file, ...args], { cwd });
Expand Down

0 comments on commit e1d357f

Please sign in to comment.