Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add integration test for create fuels #2489

Merged
merged 40 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
3e7c853
ci: separate publish step for `test.yaml`
petertonysmith94 Jun 10, 2024
4799b80
chore: added test script
petertonysmith94 Jun 11, 2024
4759ac0
chore: added path export
petertonysmith94 Jun 11, 2024
1c71a9c
chore: moved `create-fuels` install param to the options
petertonysmith94 Jun 12, 2024
ea3c388
chore: cleaned up output from integration test
petertonysmith94 Jun 12, 2024
923fe38
chore: moved install spinner
petertonysmith94 Jun 12, 2024
055d93d
chore: hooked up `PUBLISHED_NPM_VERSION`
petertonysmith94 Jun 12, 2024
bfe9246
chore: made opts `no-install`
petertonysmith94 Jun 12, 2024
f151e80
chore: changeset
petertonysmith94 Jun 12, 2024
ccecf76
chore: reorganized CI step
petertonysmith94 Jun 12, 2024
31bc310
Merge branch 'master' into ps/chore/create-fuels-integration-test
petertonysmith94 Jun 12, 2024
811af35
Merge branch 'master' into ps/chore/create-fuels-integration-test
Dhaiwat10 Jun 12, 2024
0b3d3eb
Merge branch 'master' into ps/chore/create-fuels-integration-test
petertonysmith94 Jun 14, 2024
06f10c6
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into ps…
petertonysmith94 Jun 14, 2024
6fa766c
chore: install for e2e
petertonysmith94 Jun 14, 2024
89d26bd
chore: removed redundant block
petertonysmith94 Jun 14, 2024
5f4e1e6
chore: bump FUEL_CORE version
petertonysmith94 Jun 17, 2024
2dcc684
Merge branch 'master' into ps/chore/create-fuels-integration-test
petertonysmith94 Jun 17, 2024
0ee4b9a
Merge branch 'master' into ps/chore/create-fuels-integration-test
petertonysmith94 Jun 18, 2024
e5f7f2c
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into ps…
petertonysmith94 Jun 18, 2024
26db186
chore: internal versions for script
petertonysmith94 Jun 18, 2024
3ca2d18
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into ps…
petertonysmith94 Jun 19, 2024
edf79b5
chore: renamed e2e to integration
petertonysmith94 Jun 19, 2024
0b36a5a
chore: updated comment
petertonysmith94 Jun 19, 2024
a654828
ci: moved integration to after the release step only
petertonysmith94 Jun 19, 2024
7308edf
chore: added integration to validate tests
petertonysmith94 Jun 19, 2024
31f4af8
chore: added missing bun test
petertonysmith94 Jun 20, 2024
31fe409
chore: added integration tests
petertonysmith94 Jun 21, 2024
c36636a
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into ps…
petertonysmith94 Jun 21, 2024
d2a77a9
chore: removed redundant test
petertonysmith94 Jun 21, 2024
970334a
Merge branch 'master' into ps/chore/create-fuels-integration-test
petertonysmith94 Jun 21, 2024
c431ff3
Merge branch 'master' into ps/chore/create-fuels-integration-test
arboleya Jun 24, 2024
462e327
chore: enable integration test to run on `master` and the changeset's PR
petertonysmith94 Jun 24, 2024
1f6cb70
chore: reverted incorrect change
petertonysmith94 Jun 24, 2024
8a0b1e9
Merge branch 'master' into ps/chore/create-fuels-integration-test
petertonysmith94 Jun 24, 2024
5d9cc6f
chore: revert to mess if's
petertonysmith94 Jun 24, 2024
2a92453
Merge branch 'master' into ps/chore/create-fuels-integration-test
petertonysmith94 Jun 24, 2024
f56d1ed
Merge branch 'master' into ps/chore/create-fuels-integration-test
petertonysmith94 Jun 24, 2024
15eb5d9
Update .github/workflows/test.yaml
nedsalk Jun 24, 2024
6fee0d8
Merge branch 'master' into ps/chore/create-fuels-integration-test
nedsalk Jun 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/metal-jokes-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-fuels": patch
---

chore: add integration test for `create fuels`
57 changes: 33 additions & 24 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ jobs:
path: coverage/environments/${{ matrix.env.name }}
overwrite: true

e2e:
integration:
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [environments]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -60,32 +59,36 @@ jobs:
- name: Test Setup
uses: ./.github/actions/test-setup
with:
should-install-bun: true

- name: Publish PR to NPM
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
id: release
uses: ./.github/actions/pr-release
with:
npm-token: ${{ secrets.NPM_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
should-install-bun: github.ref_name == 'master' || github.head_ref == 'changesets-release/master'

- name: Echo Published Version
run: echo ${{ steps.release.outputs.published_version }}
- name: Run UI tests (on template)
run: sh ./scripts/tests-ui.sh

- name: Pretest
run: pnpm pretest
- name: Wait for release to succeed
if: github.ref_name == 'master' || github.head_ref == 'changesets-release/master'
uses: lewagon/wait-on-check-action@v1.3.4
with:
ref: 'refs/heads/master'
check-name: "Release"
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 30

- name: Run tests (with published version)
if: github.ref_name == 'master' || github.head_ref == 'changesets-release/master'
run: pnpm test:integration
env:
PUBLISHED_NPM_VERSION: next

- name: Run Isolated Tests
run: pnpm test:e2e
- name: Run UI tests (with published version)
if: github.ref_name == 'master' || github.head_ref == 'changesets-release/master'
run: sh ./scripts/create-fuels-template-integration.sh
env:
TESTNET_WALLET_PVT_KEY: ${{ secrets.TESTNET_WALLET_PVT_KEY }}
DEVNET_WALLET_PVT_KEY: ${{ secrets.DEVNET_WALLET_PVT_KEY }}
PUBLISHED_NPM_VERSION: ${{ steps.release.outputs.published_version }}
PUBLISHED_NPM_VERSION: next

create-fuels-template-integration:
timeout-minutes: 10
e2e:
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [environments]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -95,8 +98,14 @@ jobs:
- name: Test Setup
uses: ./.github/actions/test-setup

- name: Run UI tests
run: sh ./scripts/create-fuels-template-integration.sh
- name: Pretest
run: pnpm pretest

- name: Run Isolated Tests
run: pnpm test:e2e
env:
TESTNET_WALLET_PVT_KEY: ${{ secrets.TESTNET_WALLET_PVT_KEY }}
DEVNET_WALLET_PVT_KEY: ${{ secrets.DEVNET_WALLET_PVT_KEY }}

test:
if: github.base_ref == 'master' || github.ref_name == 'master'
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"test:browser": "vitest --run --coverage --config vitest.browser.config.mts $(scripts/tests-find.sh --browser)",
"test:browser:filter": "vitest --run --coverage false --config vitest.browser.config.mts",
"test:e2e": "vitest --run --config vitest.node.config.mts $(scripts/tests-find.sh --e2e)",
"test:integration": "vitest --run --config vitest.node.config.mts $(scripts/tests-find.sh --integration)",
"lint": "run-s lint:check prettier:check",
"lint:check": "eslint . --ext .ts --max-warnings 0",
"lint:fix": "pnpm lint:check --fix",
Expand Down
1 change: 1 addition & 0 deletions packages/create-fuels/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export const runScaffoldCli = async ({

process.chdir(projectPath);
execSync(packageManager.install, { stdio: verboseEnabled ? 'inherit' : 'pipe' });

installDepsSpinner.succeed('Installed dependencies!');
}

Expand Down
4 changes: 2 additions & 2 deletions packages/create-fuels/src/lib/setupProgram.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { setupProgram } from './setupProgram';
describe('setupProgram', () => {
test('setupProgram takes in args properly', () => {
const program = setupProgram();
program.parse(['', '', 'test-project-name', '--pnpm', '--npm']);
program.parse(['', '', 'test-project-name', '--pnpm', '--npm', '--bun']);
expect(program.args[0]).toBe('test-project-name');
expect(program.opts().pnpm).toBe(true);
expect(program.opts().npm).toBe(true);
expect(program.opts().bun).toBe(undefined);
expect(program.opts().bun).toBe(true);
});

test('setupProgram - no args', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const packageManagerCreateCommands: [PackageManager, string][] = [
];

/**
* @group e2e
* @group integration
*/
describe('`create fuels` package integrity', () => {
let paths: ProjectPaths;
Expand Down
7 changes: 0 additions & 7 deletions scripts/create-fuels-template-integration.sh

This file was deleted.

2 changes: 2 additions & 0 deletions scripts/tests-find.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ elif [[ $* == *--browser* ]]; then
grep -lE "@group\s+browser" $FILES
elif [[ $* == *--e2e* ]]; then
grep -lE "@group\s+e2e" $FILES
elif [[ $* == *--integration* ]]; then
grep -lE "@group\s+integration" $FILES
fi
50 changes: 50 additions & 0 deletions scripts/tests-ui-integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

# The PUBLISHED_NPM_VERSION variable is required to create a new project with the current published `fuels` version
PUBLISHED_NPM_VERSION="${PUBLISHED_NPM_VERSION-"next"}"

# Versions
FUEL_CORE_VERSION=$(cat ./internal/fuel-core/VERSION)
FORC_VERSION=$(cat ./internal/forc/VERSION)
TOOLCHAIN="CI"

# Project
ROOT_DIR=$(pwd)
PLAYWRIGHT_DIR="$ROOT_DIR"
PROJECT_DIR="$ROOT_DIR/test-project"

echo "1. Install toolchains"
if [ -x "$(command -v fuelup)" ]; then
echo "Fuelup exists"
else
echo "Fuelup does not exist - installing 'fuelup'"
curl -fsSL https://install.fuel.network/ | sh -s -- --no-modify-path
export PATH="${HOME}/.fuelup/bin:${PATH}"
fi

fuelup toolchain new $TOOLCHAIN
fuelup default $TOOLCHAIN
fuelup component add fuel-core@$FUEL_CORE_VERSION
fuelup component add forc@$FORC_VERSION

echo "2. Scaffold a new project with 'create fuels@$PUBLISHED_NPM_VERSION'"
if [ -d "$PROJECT_DIR" ]; then
echo "Removing existing project directory '$PROJECT_DIR'"
rm -rf $PROJECT_DIR
fi
pnpm create fuels@$PUBLISHED_NPM_VERSION $PROJECT_DIR --pnpm -cps --no-install

echo "3. Intialise the project"
cd $PROJECT_DIR
pnpm add fuels@$PUBLISHED_NPM_VERSION > /dev/null 2>&1
pnpm --ignore-workspace install > /dev/null 2>&1
cp .env.example .env.local

echo "4. Running UI tests"
cd $ROOT_DIR
PROJECT_DIR=$PROJECT_DIR sh ./scripts/tests-ui.sh
TEST_RESULT=$?

rm -rf $PROJECT_DIR

exit $TEST_RESULT
18 changes: 18 additions & 0 deletions scripts/tests-ui.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

ROOT_DIR=$(pwd)
PLAYWRIGHT_DIR="$ROOT_DIR"
PROJECT_DIR="${PROJECT_DIR-"$ROOT_DIR/templates/nextjs"}"

cd $PROJECT_DIR && pnpm run fuels:dev > /dev/null 2>&1 &
sleep 5

cd $PROJECT_DIR && pnpm run dev > /dev/null 2>&1 &
sleep 5

cd $PLAYWRIGHT_DIR
pnpm exec playwright install --with-deps
pnpm exec playwright test

pkill next-server
pkill fuel-core
2 changes: 1 addition & 1 deletion scripts/tests-validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ROOT=$(cd "$(dirname "$0")/.."; pwd)

FILES=$(find $ROOT/{apps,packages,internal} -name '*.test.ts')
INVALID_FILES=$(grep -LE "@group\s+(node|browser|e2e)" $FILES)
INVALID_FILES=$(grep -LE "@group\s+(node|browser|e2e|integration)" $FILES)

if [ ! -z "$INVALID_FILES" ]; then
echo -e "Test files don't contain a test environment configuration:"
Expand Down
Loading