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

Add Wf to update Gear tag in cargo.toml #415

Merged
merged 7 commits into from
Jul 20, 2024
Merged
Changes from all commits
Commits
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
9 changes: 6 additions & 3 deletions .github/workflows/UpdateGearDependency.yml
Original file line number Diff line number Diff line change
@@ -25,14 +25,17 @@ jobs:
- name: Install GitPython
run: |
python -m pip install --upgrade pip
pip install gitpython
pip install requests packaging gitpython

- name: Check for new tag and update Cargo.toml
env:
GITHUB_TOKEN: ${{ secrets.UPDATE_GEAR_TAG_TOKEN }}
run: |
python update_cargo_toml.py
if ! git diff --exit-code; then
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add Cargo.toml
git commit -m "Update dependencies to latest tag"
git add ../contracts/Cargo.toml
git commit -m "Update GEAR dependencies to latest tag in contracts"
git push
fi
38 changes: 38 additions & 0 deletions scripts/update_cargo_toml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import re
import requests
from packaging import version

# GitHub API URL to get the latest tags
GEAR_REPO_TAGS_URL = "https://api.github.com/repos/gear-tech/gear/tags"

# ABSOLUTE PATH to cargo file
CARGO_FILE_PATH = '../contracts/Cargo.toml'

def get_latest_semver_tag():
response = requests.get(GEAR_REPO_TAGS_URL)
response.raise_for_status()
tags = response.json()
# Filter out tags that are not valid semantic versions
valid_tags = [tag['name'] for tag in tags if re.match(r'^v?\d+\.\d+\.\d+$', tag['name'])]
# Sort the valid tags by version
valid_tags.sort(key=lambda s: version.parse(s.lstrip('v')), reverse=True)
return valid_tags[0] if valid_tags else None

def update_cargo_toml(file_path, new_version):
with open(file_path, 'r') as file:
content = file.read()

content = re.sub(r'gstd = ".*?"', f'gstd = "{new_version}"', content)
content = re.sub(r'gear-wasm-builder = ".*?"', f'gear-wasm-builder = "{new_version}"', content)
content = re.sub(r'gmeta = ".*?"', f'gmeta = "{new_version}"', content)
content = re.sub(r'gclient = ".*?"', f'gclient = "{new_version}"', content)
content = re.sub(r'gtest = { git = "https://github.com/gear-tech/gear", tag = ".*?" }', f'gtest = {{ git = "https://github.com/gear-tech/gear", tag = "v{new_version}" }}', content)
content = re.sub(r'gear-core = ".*?"', f'gear-core = "{new_version}"', content)

with open(file_path, 'w') as file:
file.write(content)

if __name__ == "__main__":
new_version = get_latest_semver_tag().lstrip('v')
if new_version:
update_cargo_toml('../contracts/Cargo.toml', new_version)

Unchanged files with check annotations Beta

setIsAdmin([owner, allowedAccount].includes(decodedAddress));
setIsInit((prev) => !prev);
}
}, [state, isStateRead, account, error, isInit, lesson]);

Check warning on line 48 in frontend/apps/tamagotchi/src/app/hooks/use-tamagotchi.ts

GitHub Actions / build (apps/tamagotchi, build)

React Hook useEffect has missing dependencies: 'resetLesson', 'setIsAdmin', 'setIsReady', and 'setTamagotchi'. Either include them or remove the dependency array
}
export function useTamagotchiMessage() {
return () => {
unsub.then((unsubCallback) => unsubCallback());
};
}, [api, programId, wasm, programMetadata, functionName, argument, payload]);

Check warning on line 83 in frontend/apps/tamagotchi/src/app/hooks/use-read-wasm-state.ts

GitHub Actions / build (apps/tamagotchi, build)

React Hook useEffect has missing dependencies: 'handleStateChange', 'isArgument', and 'isPayload'. Either include them or remove the dependency array
useEffect(() => {
readWasmState(true);
setError('');
}, [api, programId, wasm, programMetadata, functionName, argument, payload]);

Check warning on line 88 in frontend/apps/tamagotchi/src/app/hooks/use-read-wasm-state.ts

GitHub Actions / build (apps/tamagotchi, build)

React Hook useEffect has a missing dependency: 'readWasmState'. Either include it or remove the dependency array
useEffect(() => {
if (error) alert.error(error);
}, [error]);

Check warning on line 92 in frontend/apps/tamagotchi/src/app/hooks/use-read-wasm-state.ts

GitHub Actions / build (apps/tamagotchi, build)

React Hook useEffect has a missing dependency: 'alert'. Either include it or remove the dependency array
// contract calculates new state on read without MessagesDispatched events
useEffect(() => {
return () => {
clearInterval(interval);
};
}, [state]);

Check warning on line 103 in frontend/apps/tamagotchi/src/app/hooks/use-read-wasm-state.ts

GitHub Actions / build (apps/tamagotchi, build)

React Hook useEffect has a missing dependency: 'readWasmState'. Either include it or remove the dependency array
return { state, isStateRead, error, readWasmState };
}
const [, meta] = useLessonAssets();
const { tamagotchi, setTamagotchi } = useTamagotchi();
const { state, readWasmState } = useReadWasmState<StateWasmResponse>({

Check warning on line 116 in frontend/apps/tamagotchi/src/app/hooks/use-read-wasm-state.ts

GitHub Actions / build (apps/tamagotchi, build)

'readWasmState' is assigned a value but never used
programId: lesson?.programId,
wasm: stateMeta?.buffer,
programMetadata: meta,
}
} else localStorage.removeItem(key);
}
}, [assets, lesson]);

Check warning on line 25 in frontend/apps/tamagotchi/src/app/hooks/use-lessons.ts

GitHub Actions / build (apps/tamagotchi, build)

React Hook useEffect has a missing dependency: 'setLesson'. Either include it or remove the dependency array
}
import { Button, buttonStyles, Input, Select } from '@gear-js/ui';

Check warning on line 1 in frontend/apps/tamagotchi/src/components/forms/create-tamagotchi-form/create-tamagotchi-form.tsx

GitHub Actions / build (apps/tamagotchi, build)

'Select' is defined but never used
import { useForm } from '@mantine/form';
import { hexRequired } from '@/app/utils/form-validations';
import { useApp, useLessons } from '@/app/context';
programId: hexRequired,
};
const options = [

Check warning on line 13 in frontend/apps/tamagotchi/src/components/forms/create-tamagotchi-form/create-tamagotchi-form.tsx

GitHub Actions / build (apps/tamagotchi, build)

'options' is assigned a value but never used
{ value: 1, label: 'Lesson 1' },
{ value: 2, label: 'Lesson 2' },
{ value: 3, label: 'Lesson 3' },
} else {
setItemsUsed(hasItem);
}
}, [tamagotchiItems]);

Check warning on line 56 in frontend/apps/tamagotchi/src/components/tamagotchi/tamagotchi-avatar/tamagotchi-avatar.tsx

GitHub Actions / build (apps/tamagotchi, build)

React Hook useEffect has missing dependencies: 'hasItem' and 'inBattle'. Either include them or remove the dependency array. If 'setItemsUsed' needs the current value of 'hasItem', you can also switch to useReducer instead of useState and read 'hasItem' in the reducer
useEffect(() => {
if (energy && !isActive) {
import { Header } from '@tanstack/table-core';
import clsx from 'clsx';

Check warning on line 2 in frontend/apps/battleship/src/components/ui/data-table/data-table-header-actions.tsx

GitHub Actions / build (apps/battleship, build)

'clsx' is defined but never used
import { ArrowDownAZ, ArrowUpAZ } from 'lucide-react';
import { CaretDown } from '@/assets/images';
import styles from './table.module.scss';
const { length, degrees } = ship;
return (
<img

Check warning on line 95 in frontend/apps/battleship/src/features/game/components/map/mapEnemy.tsx

GitHub Actions / build (apps/battleship, build)

img elements must have an alt prop, either with meaningful text, or an empty string for decorative images
src={ships[`shipX${length}SVG`]}
style={{
position: 'absolute',
export function WalletChange({ onClose, openConnectWallet }: Props) {
const { account, logout } = useAccount();
const isGamePage = useIsLocationGamePage();

Check warning on line 23 in frontend/apps/battleship/src/features/wallet/components/wallet-change/WalletChange.tsx

GitHub Actions / build (apps/battleship, build)

'isGamePage' is assigned a value but never used
const { walletAccounts } = useWallet();
const getAccounts = () =>
} else {
setIsReady(true);
}
}, [account, api, isAccountReady, isApiReady, isReady, balance]);

Check warning on line 102 in frontend/apps/battleship/src/features/wallet/hooks.ts

GitHub Actions / build (apps/battleship, build)

React Hook useEffect has missing dependencies: 'setAvailableBalance' and 'setIsReady'. Either include them or remove the dependency array
}
export { useWalletSync, useWallet, useAccountAvailableBalance, useAccountAvailableBalanceSync };
if (tournamentGame) {
setPreviousGame(tournamentGame);
}
}, [tournamentGame]);

Check warning on line 14 in frontend/apps/vara-man/src/pages/home.tsx

GitHub Actions / build (apps/vara-man, build)

React Hook useEffect has a missing dependency: 'setPreviousGame'. Either include it or remove the dependency array
return <>{tournamentGame || previousGame ? <Game /> : <HomeRegister />}</>;
}
className="col-start-1 group level-mode level-mode--to-right p-2.5 hover:[--from:#16B768]"
onClick={() => paginate(-1)}>
<span className="before:absolute before:inset-0 before:z-0 before:bg-[#1e1e1e] before:rounded-[8px] group-hover:before:bg-primary before:transition-colors" />
<Icons.sliderPrev className="relative z-1 w-5 h-5 text-primary group-hover:text-white" />

Check warning on line 92 in frontend/apps/vara-man/src/pages/rules.tsx

GitHub Actions / build (apps/vara-man, build)

Imported JSX component sliderPrev must be in PascalCase or SCREAMING_SNAKE_CASE
</button>
)}
{page < images.length - 1 && (
<button className="col-start-2 group level-mode p-2.5 hover:[--from:#16B768]" onClick={() => paginate(1)}>
<span className="before:transition-colors before:absolute before:inset-0 before:z-0 before:bg-[#1e1e1e] before:rounded-[8px] group-hover:before:bg-primary" />
<Icons.sliderNext className="relative z-1 w-5 h-5 text-primary group-hover:text-white transition-colors" />

Check warning on line 99 in frontend/apps/vara-man/src/pages/rules.tsx

GitHub Actions / build (apps/vara-man, build)

Imported JSX component sliderNext must be in PascalCase or SCREAMING_SNAKE_CASE
</button>
)}
</div>
<CommonHeader
logo={
<Link to="/">
<Icons.logo className="h-15" />

Check warning on line 19 in frontend/apps/vara-man/src/components/layout/header/header.tsx

GitHub Actions / build (apps/vara-man, build)

Imported JSX component logo must be in PascalCase or SCREAMING_SNAKE_CASE
</Link>
}
menu={
import { useEffect } from 'react';

Check warning on line 1 in frontend/apps/vara-man/src/components/sections/home/home-register.tsx

GitHub Actions / build (apps/vara-man, build)

'useEffect' is defined but never used
import { useAccount, useAlert } from '@gear-js/react-hooks';
import { useNavigate, NavigateFunction } from 'react-router-dom';
import { ArrowRight, Search } from 'lucide-react';

Check warning on line 4 in frontend/apps/vara-man/src/components/sections/home/home-register.tsx

GitHub Actions / build (apps/vara-man, build)

'Search' is defined but never used
import { WalletNew } from '@dapps-frontend/ui/';
import IntroImage from '@/assets/images/welcome.png';
import { Icons } from '@/components/ui/icons';
{
title: 'Just play and have fun!',
description: 'Start the game without any preparations right now.',
icon: <Icons.gameJoystick />,

Check warning on line 15 in frontend/apps/vara-man/src/components/sections/home/home-register.tsx

GitHub Actions / build (apps/vara-man, build)

Imported JSX component gameJoystick must be in PascalCase or SCREAMING_SNAKE_CASE
onClick: (navigate: NavigateFunction): void => {
navigate('/levels');
},
{
title: 'Find a private game',
description: "To find the game, you need to enter the administrator's address.",
icon: <Icons.search />,

Check warning on line 23 in frontend/apps/vara-man/src/components/sections/home/home-register.tsx

GitHub Actions / build (apps/vara-man, build)

Imported JSX component search must be in PascalCase or SCREAMING_SNAKE_CASE
onClick: (navigate: NavigateFunction): void => {
navigate('/tournament/find');
},
{
title: 'Create your private game',
description: 'Create your own game tournament and compete with friends.',
icon: <Icons.admin />,

Check warning on line 31 in frontend/apps/vara-man/src/components/sections/home/home-register.tsx

GitHub Actions / build (apps/vara-man, build)

Imported JSX component admin must be in PascalCase or SCREAMING_SNAKE_CASE
onClick: (navigate: NavigateFunction): void => {
navigate('/tournament/create');
},
{item.enemies} enemies
<div className="flex mt-2">
{Array.from({ length: 8 }).map((_, index) => {
return index < item.enemies ? <Icons.skull key={index} /> : <Icons.skullDisable key={index} />;

Check warning on line 60 in frontend/apps/vara-man/src/components/sections/levels/levels-select-mode.tsx

GitHub Actions / build (apps/vara-man, build)

Imported JSX component skull must be in PascalCase or SCREAMING_SNAKE_CASE
})}
</div>
</div>
useEffect(() => {
setIsLoading(isOpened);
}, [isOpened]);

Check warning on line 85 in frontend/apps/tic-tac-toe/src/features/tic-tac-toe/components/game-field/game-field.tsx

GitHub Actions / build (apps/tic-tac-toe, build)

React Hook useEffect has a missing dependency: 'setIsLoading'. Either include it or remove the dependency array
return (
<div