Skip to content

Commit

Permalink
feat: improve relase ci (#953)
Browse files Browse the repository at this point in the history
  • Loading branch information
luizstacio authored Oct 27, 2023
1 parent c2baa3c commit b77b224
Show file tree
Hide file tree
Showing 21 changed files with 223 additions and 46 deletions.
2 changes: 2 additions & 0 deletions .changeset/khaki-lobsters-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
4 changes: 2 additions & 2 deletions .github/workflows/release-npm-latest.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: "Release"
name: "Release latest"

on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/release-npm-preview.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Release to @preview tag on npm

on:
workflow_dispatch:

env:
BUILD_VERSION: ""

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
release-changesets:
name: Release to @preview tag on npm
runs-on: buildjet-4vcpu-ubuntu-2204
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: FuelLabs/github-actions/setups/node@master
- uses: FuelLabs/github-actions/setups/npm@master
with:
npm-token: ${{ secrets.NPM_TOKEN }}

- name: Build Libs
run: pnpm build:libs
env:
## increase node.js m memory limit for building
## with sourcemaps
NODE_OPTIONS: "--max-old-space-size=4096"

- name: Release to @preview tag on npm
id: release
run: |
pnpm changeset version --snapshot preview
changetsets=$(pnpm changeset publish --tag preview)
echo "BUILD_VERSION=$(pnpm -s packages:version)" >> $GITHUB_ENV
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Comment release package name to PR
uses: mshick/add-pr-comment@v2
with:
message: |
This PR is published in NPM with version **${{ env.BUILD_VERSION }}**
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/release-npm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ on:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
BUILD_VERSION: ""

jobs:
release-changesets:
name: Changesets Release
name: Release master or rc
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
id: changesets
uses: FuelLabs/changesets-action@main
with:
publish: pnpm changeset publish --tag next
publish: pnpm changeset publish --tag rc
commit: "ci(changesets): versioning packages"
title: "ci(changesets): versioning packages"
createGithubReleases: aggregate
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/unpublish-npm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Unpublish old versions"

on:
workflow_dispatch:
inputs:
delete_packages:
type: boolean
description: Delete packages? otherwise dry-run mode will be used
default: false

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
clean-npm-versions:
name: Unpublish versions next, preview, master...
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- uses: FuelLabs/github-actions/setups/node@master
- uses: FuelLabs/github-actions/setups/npm@master
with:
npm-token: ${{ secrets.NPM_TOKEN }}
- run: |
node ./scripts/unpublish.js
env:
DELETE_PACKAGES: ${{ github.event.inputs.delete_packages}}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"dependencies": {
"@fuel-ui/css": "0.21.1",
"@fuel-ui/react": "0.21.1",
"compare-versions": "^6.1.0",
"execa": "^8.0.1"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/app/playwright/commons/seedWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getGasConfig } from './gas';

const { GENESIS_SECRET, VITE_FUEL_PROVIDER_URL } = process.env;

export async function seedCurretAccount(page: Page, amount: BN) {
export async function seedCurrentAccount(page: Page, amount: BN) {
const account = await getAccount(page);
await seedWallet(account.address, amount);
}
Expand All @@ -28,7 +28,7 @@ export async function seedWallet(address: string, amount: BN) {
Address.fromString(address),
amount,
ALT_ASSET.assetId,
{ gasPrice, gasLimit }
{ gasPrice, gasLimit: 110_000 }
);
await transfAsset.wait();
}
4 changes: 4 additions & 0 deletions packages/app/playwright/commons/visit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import type { Page } from '@playwright/test';

export async function visit(page: Page, pathname: string) {
// Ensure page is reloaded if already in the same page
if (page.url().endsWith(pathname)) {
await page.reload();
}
const pageFinal = await page.goto(`#${pathname}`);
// Using waitUntil: 'networkidle' has interminent issues
await page.waitForTimeout(1000);
Expand Down
8 changes: 4 additions & 4 deletions packages/app/playwright/crx/crx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ test.describe('FuelWallet Extension', () => {
/** Adding password */
await hasText(page, /Create password for encryption/i);
const passwordInput = getByAriaLabel(page, 'Your Password');
await passwordInput.type(WALLET_PASSWORD);
await passwordInput.fill(WALLET_PASSWORD);
await passwordInput.press('Tab');
const confirmPasswordInput = getByAriaLabel(page, 'Confirm Password');
await confirmPasswordInput.type(WALLET_PASSWORD);
await confirmPasswordInput.fill(WALLET_PASSWORD);
await confirmPasswordInput.press('Tab');

await getButtonByText(page, /Next/i).click();
Expand Down Expand Up @@ -185,10 +185,10 @@ test.describe('FuelWallet Extension', () => {
await waitWalletToLoad(popupPage);
await getByAriaLabel(popupPage, 'Accounts').click();
await getByAriaLabel(popupPage, 'Import from private key').click();
await getByAriaLabel(popupPage, 'Private Key').type(privateKey);
await getByAriaLabel(popupPage, 'Private Key').fill(privateKey);
if (name) {
await getByAriaLabel(popupPage, 'Account Name').clear();
await getByAriaLabel(popupPage, 'Account Name').type(name);
await getByAriaLabel(popupPage, 'Account Name').fill(name);
}
await getByAriaLabel(popupPage, 'Import').click();
await waitAccountPage(popupPage, name);
Expand Down
6 changes: 3 additions & 3 deletions packages/app/playwright/e2e/Accounts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ test.describe('Account', () => {
await getByAriaLabel(page, `Export ${data.accounts[0].name}`).click();

await hasText(page, 'Unlock your wallet to continue');
await getByAriaLabel(page, 'Your Password').type(WALLET_PASSWORD);
await getByAriaLabel(page, 'Your Password').fill(WALLET_PASSWORD);
await getByAriaLabel(page, 'Unlock wallet').click();
await hasText(page, /Export Private Key/i);
await hasText(page, data.accounts[0].privateKey);
Expand Down Expand Up @@ -142,11 +142,11 @@ test.describe('Account', () => {

await hasText(page, 'Unlock your wallet to continue');
const passwordInput = getByAriaLabel(page, 'Your Password');
await passwordInput.type(`${WALLET_PASSWORD}1`);
await passwordInput.fill(`${WALLET_PASSWORD}1`);
await getByAriaLabel(page, 'Unlock wallet').click();
await hasText(page, /Invalid password/i);
await passwordInput.clear();
await passwordInput.type(WALLET_PASSWORD);
await passwordInput.fill(WALLET_PASSWORD);
await getByAriaLabel(page, 'Unlock wallet').click();
await hasText(page, /Export Private Key/i);
await hasText(page, data.accounts[0].privateKey);
Expand Down
10 changes: 5 additions & 5 deletions packages/app/playwright/e2e/Asset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ test.describe('Asset', () => {
await hasText(page, /Listed/i);
await getByAriaLabel(page, 'Add Asset').click();
await hasText(page, 'Save');
await getByAriaLabel(page, 'Asset ID').type(CUSTOM_ASSET.assetId);
await getByAriaLabel(page, 'Asset name').type(CUSTOM_ASSET.name);
await getByAriaLabel(page, 'Asset symbol').type(CUSTOM_ASSET.symbol);
await getByAriaLabel(page, 'Asset decimals').type(
await getByAriaLabel(page, 'Asset ID').fill(CUSTOM_ASSET.assetId);
await getByAriaLabel(page, 'Asset name').fill(CUSTOM_ASSET.name);
await getByAriaLabel(page, 'Asset symbol').fill(CUSTOM_ASSET.symbol);
await getByAriaLabel(page, 'Asset decimals').fill(
String(CUSTOM_ASSET.decimals)
);
await getByAriaLabel(page, 'Asset image Url').type(CUSTOM_ASSET.imageUrl);
await getByAriaLabel(page, 'Asset image Url').fill(CUSTOM_ASSET.imageUrl);
await getByAriaLabel(page, 'Save Asset').click();
await waitUrl(page, '/assets');
await hasText(page, /Listed/i);
Expand Down
18 changes: 9 additions & 9 deletions packages/app/playwright/e2e/ChangePassword.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ test.describe('ChangePassword', () => {
await hasText(page, /Change Password/i);

// fills form data
await getByAriaLabel(page, 'Current Password').type(WALLET_PASSWORD);
await getByAriaLabel(page, 'New Password').type('newPass12345$');
await getByAriaLabel(page, 'Confirm Password').type('newPass12345$');
await getByAriaLabel(page, 'Current Password').fill(WALLET_PASSWORD);
await getByAriaLabel(page, 'New Password').fill('newPass12345$');
await getByAriaLabel(page, 'Confirm Password').fill('newPass12345$');

// submit data
await hasText(page, 'Save');
Expand All @@ -41,9 +41,9 @@ test.describe('ChangePassword', () => {
await hasText(page, /Change Password/i);

// fills form data
await getByAriaLabel(page, 'Current Password').type('wrongPass123$');
await getByAriaLabel(page, 'New Password').type('newPass12345$');
await getByAriaLabel(page, 'Confirm Password').type('newPass12345$');
await getByAriaLabel(page, 'Current Password').fill('wrongPass123$');
await getByAriaLabel(page, 'New Password').fill('newPass12345$');
await getByAriaLabel(page, 'Confirm Password').fill('newPass12345$');

// submit data
await hasText(page, 'Save');
Expand All @@ -59,9 +59,9 @@ test.describe('ChangePassword', () => {
await hasText(page, /Change Password/i);

// fills form data
await getByAriaLabel(page, 'Current Password').type('12345678');
await getByAriaLabel(page, 'New Password').type('newPass12345$');
await getByAriaLabel(page, 'Confirm Password').type('newPass123456$');
await getByAriaLabel(page, 'Current Password').fill('12345678');
await getByAriaLabel(page, 'New Password').fill('newPass12345$');
await getByAriaLabel(page, 'Confirm Password').fill('newPass123456$');
await getByAriaLabel(page, 'Confirm Password').blur();

await hasText(page, 'Passwords must match');
Expand Down
4 changes: 2 additions & 2 deletions packages/app/playwright/e2e/CreateWallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ test.describe('CreateWallet', () => {
/** Adding password */
await hasText(page, /Create password for encryption/i);
const passwordInput = getByAriaLabel(page, 'Your Password');
await passwordInput.type(WALLET_PASSWORD);
await passwordInput.fill(WALLET_PASSWORD);
await passwordInput.press('Tab');
const confirmPasswordInput = getByAriaLabel(page, 'Confirm Password');
await confirmPasswordInput.type(WALLET_PASSWORD);
await confirmPasswordInput.fill(WALLET_PASSWORD);
await confirmPasswordInput.press('Tab');

await getButtonByText(page, /Next/i).click();
Expand Down
8 changes: 4 additions & 4 deletions packages/app/playwright/e2e/RecoverWallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ test.describe('RecoverWallet', () => {
/** Adding password */
await hasText(page, /Create password for encryption/i);
const passwordInput = getByAriaLabel(page, 'Your Password');
await passwordInput.type(WALLET_PASSWORD);
await passwordInput.fill(WALLET_PASSWORD);
await passwordInput.press('Tab');
const confirmPasswordInput = getByAriaLabel(page, 'Confirm Password');
await confirmPasswordInput.type(WALLET_PASSWORD);
await confirmPasswordInput.fill(WALLET_PASSWORD);
await confirmPasswordInput.press('Tab');

await getButtonByText(page, /Next/i).click();
Expand Down Expand Up @@ -92,10 +92,10 @@ test.describe('RecoverWallet', () => {
/** Adding password */
await hasText(page, /Create password for encryption/i);
const passwordInput = getByAriaLabel(page, 'Your Password');
await passwordInput.type(WALLET_PASSWORD);
await passwordInput.fill(WALLET_PASSWORD);
await passwordInput.press('Tab');
const confirmPasswordInput = getByAriaLabel(page, 'Confirm Password');
await confirmPasswordInput.type(WALLET_PASSWORD);
await confirmPasswordInput.fill(WALLET_PASSWORD);
await confirmPasswordInput.press('Tab');

await getButtonByText(page, /Next/i).click();
Expand Down
14 changes: 7 additions & 7 deletions packages/app/playwright/e2e/SendTransaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ test.describe('SendTransaction', () => {
await page.getByText('Ethereum').click();

// Fill address
await getInputByName(page, 'address').type(
await getInputByName(page, 'address').fill(
receiverWallet.address.toString()
);

// Fill amount
await getInputByName(page, 'amount').type('0.001');
await getInputByName(page, 'amount').fill('0.001');

// Submit transaction
await getButtonByText(page, 'Confirm').click();
Expand All @@ -72,10 +72,10 @@ test.describe('SendTransaction', () => {
await page.getByText('Ethereum').click();

// Fill address
await getInputByName(page, 'address').type(account.address.toString());
await getInputByName(page, 'address').fill(account.address.toString());

// Fill amount
await getInputByName(page, 'amount').type('0.001');
await getInputByName(page, 'amount').fill('0.001');

// Submit transaction
await getButtonByText(page, 'Confirm').click();
Expand All @@ -102,12 +102,12 @@ test.describe('SendTransaction', () => {
await page.getByText(ALT_ASSET.name).click();

// Fill address
await getInputByName(page, 'address').type(
await getInputByName(page, 'address').fill(
receiverWallet.address.toString()
);

// Fill amount
await getInputByName(page, 'amount').type('0.01');
await getInputByName(page, 'amount').fill('0.01');
// Check the balance is correct formated with only 2 decimals
await hasAriaLabel(page, 'Balance: 1,000,000.00');

Expand Down Expand Up @@ -136,7 +136,7 @@ test.describe('SendTransaction', () => {
await page.getByText('Ethereum').click();

// Fill address
await getInputByName(page, 'address').type(
await getInputByName(page, 'address').fill(
receiverWallet.address.toString()
);

Expand Down
4 changes: 2 additions & 2 deletions packages/app/playwright/e2e/UnlockScreen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test.describe('UnlockScreen', () => {
await hasText(page, 'Unlock your wallet to continue');
await reload(page);
await hasText(page, 'Unlock your wallet to continue');
await getByAriaLabel(page, 'Your Password').type(WALLET_PASSWORD);
await getByAriaLabel(page, 'Your Password').fill(WALLET_PASSWORD);
await getByAriaLabel(page, 'Unlock wallet').click();
await hasText(page, /assets/i);
await reload(page);
Expand All @@ -32,7 +32,7 @@ test.describe('UnlockScreen', () => {
await getByAriaLabel(page, 'Menu').click();
await page.getByText(/Lock Wallet/i).click();
await hasText(page, 'Unlock your wallet to continue');
await getByAriaLabel(page, 'Your Password').type(WALLET_PASSWORD);
await getByAriaLabel(page, 'Your Password').fill(WALLET_PASSWORD);
await getByAriaLabel(page, 'Unlock wallet').click();
await hasText(page, /assets/i);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/app/playwright/e2e/ViewRecoveryPhrase.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ test.describe('ViewSeedPhrase', () => {

// Should show unlock screen
await hasText(page, /Confirm your Password/i);
await getByAriaLabel(page, 'Your Password').type(WALLET_PASSWORD);
await getByAriaLabel(page, 'Your Password').fill(WALLET_PASSWORD);
await getButtonByText(page, 'Unlock').click();
});

Expand Down
2 changes: 1 addition & 1 deletion packages/app/playwright/mocks/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export async function unlock(page, password = WALLET_PASSWORD) {
await reload(page);
try {
await hasText(page, 'Welcome back');
await getByAriaLabel(page, 'Your Password').type(password);
await getByAriaLabel(page, 'Your Password').fill(password);
await getByAriaLabel(page, 'Unlock wallet').click();
} catch (err) {
// Ignore
Expand Down
Loading

0 comments on commit b77b224

Please sign in to comment.