Skip to content

Commit

Permalink
Merge pull request #109 from cosmology-tech/pkg/types
Browse files Browse the repository at this point in the history
types
  • Loading branch information
pyramation authored May 1, 2024
2 parents 3c05e0b + d5e7606 commit 62c986b
Show file tree
Hide file tree
Showing 17 changed files with 261 additions and 111 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Codegen Dry Run
name: Codegen Main Dry Run

on:

Expand All @@ -19,15 +19,25 @@ jobs:
node-version: '20.x'
registry-url: https://registry.npmjs.org/

- name: Code Generation
- name: Update Git Submodules 🔄
run: |
make use-cosmos
- name: Install Dependencies 🧶
run: |
yarn install
yarn symlink
- name: Build Project 🏗️
run: |
yarn build
yarn symlink
- name: Code Generation 🛠
run: |
git submodule update --remote
CHANGES_DESC="build-$(date +%Y%m%d-%H%M%S)"
yarn
yarn codegen
git add .
if ! git diff --staged --quiet; then
echo "build 🛠 $CHANGES_DESC"
echo "GIT_RESULT=Changes detected." >> $GITHUB_ENV
else
echo "GIT_RESULT=No changes to commit." >> $GITHUB_ENV
Expand Down
76 changes: 76 additions & 0 deletions .github/workflows/codegen-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Codegen Main

on:
schedule:
# Runs every day at 1:00 AM UTC
- cron: "0 1 * * *"

workflow_dispatch:

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository 📥
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Setup Node.js 🌐
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: https://registry.npmjs.org/

- name: Update Git Submodules 🔄
run: |
make use-cosmos
- name: Install Dependencies 🧶
run: |
yarn install
yarn symlink
- name: Build Project 🏗️
run: |
yarn build
yarn symlink
- name: Code Generation 🛠
run: |
# Code generation and build for various packages
pushd packages/chain-registry
yarn codegen
yarn build
popd
pushd packages/assets
yarn codegen
popd
pushd packages/osmosis
yarn codegen
popd
pushd packages/juno
yarn codegen
popd
# Stage all changes and commit if there are any changes
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git add .
if ! git diff --staged --quiet; then
git commit -am "build 🛠 build-$(date +%Y%m%d-%H%M%S)"
git push origin main
echo "GIT_RESULT=Published." >> $GITHUB_ENV
else
echo "GIT_RESULT=No changes to commit." >> $GITHUB_ENV
fi
- name: Git Ops
run: |
echo $GIT_RESULT
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_PUBLISH_SECRET}}
GH_TOKEN: ${{ secrets.GH_LERNA_PUBLISH_TOKEN }}
49 changes: 31 additions & 18 deletions .github/workflows/codegen-types-dryrun.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Generate Types Dryrun
name: Generate Types Dry Run

on:
workflow_dispatch:
Expand All @@ -20,36 +20,49 @@ jobs:

- name: Update Git Submodules 🔄
run: |
git submodule update --remote
cd packages/chain-registry/chain-registry
make use-cosmos
- name: Types Generation
- name: Install Dependencies 🧶
run: |
yarn install
yarn symlink
- name: Build Project 🏗️
run: |
git submodule update --remote
CHANGES_DESC="build-$(date +%Y%m%d-%H%M%S)"
yarn
yarn build
yarn symlink
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor}}@users.noreply.github.com"
cd v2/types
yarn types
- name: Types Generation 🛠
run: |
# Generate types and interfaces
pushd workflows/generate-types
yarn generate:types
yarn generate:interfaces
popd
# Build types
pushd v2/types
yarn build
cd ../../
cd v2/interfaces
yarn types
popd
# Build interfaces
pushd v2/interfaces
yarn build
cd ../../
cd v2/chain-registry
popd
# Generate and build code for chain registry
pushd v2/chain-registry
yarn codegen
yarn build
cd ../../
popd
# check changes
git add .
if ! git diff --staged --quiet; then
echo "GIT_RESULT=Changes to commit and/or publish." >> $GITHUB_ENV
else
echo "GIT_RESULT=No changes to commit." >> $GITHUB_ENV
fi
- name: Git Ops
- name: Git Result
run: |
echo $GIT_RESULT
50 changes: 35 additions & 15 deletions .github/workflows/codegen-types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,54 @@ jobs:

- name: Update Git Submodules 🔄
run: |
git submodule update --remote
cd packages/chain-registry/chain-registry
make use-cosmos
- name: Types Generation
- name: Install Dependencies 🧶
run: |
yarn install
yarn symlink
- name: Build Project 🏗️
run: |
git submodule update --remote
CHANGES_DESC="build-$(date +%Y%m%d-%H%M%S)"
yarn
yarn build
yarn symlink
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor}}@users.noreply.github.com"
cd v2/types
yarn types
- name: Types Generation 🛠
run: |
# Generate types and interfaces
pushd workflows/generate-types
yarn generate:types
yarn generate:interfaces
popd
# Build types
pushd v2/types
yarn build
cd ../../
cd v2/interfaces
yarn types
popd
# Build interfaces
pushd v2/interfaces
yarn build
popd
# Generate and build code for chain registry
pushd v2/chain-registry
yarn codegen
yarn build
cd ../../
popd
# Stage all changes and commit if there are any changes
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git add .
if ! git diff --staged --quiet; then
git commit -am "build 🛠 $CHANGES_DESC"
git commit -am "build 🛠 build-$(date +%Y%m%d-%H%M%S)"
git push origin main
echo "GIT_RESULT=Published." >> $GITHUB_ENV
else
echo "GIT_RESULT=No changes to commit." >> $GITHUB_ENV
fi
- name: Git Ops
run: |
echo $GIT_RESULT
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lerna-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Lerna Publish

on:
workflow_run:
workflows: ["Publish Main"]
workflows: ["Codegen Main"]
types:
- completed

Expand Down
55 changes: 0 additions & 55 deletions .github/workflows/npm-publish-main.yml

This file was deleted.

9 changes: 4 additions & 5 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@ jobs:

- name: Update Git Submodules 🔄
run: |
git submodule update --remote
cd packages/chain-registry/chain-registry
git fetch
git checkout b3dcd322284b332c1ef9458926dbcdf2985aac3e
make use-fixtures
- name: Install Dependencies 🧶
run: |
yarn install
yarn symlink
- name: Build Project 🏗️
run: yarn build
run: |
yarn build
yarn symlink
- name: Test @chain-registry/keplr 🔍
run: cd packages/keplr && yarn test
Expand Down
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
.PHONY: def use-cosmos use-fixtures

def:
git submodule update --remote
def: use-cosmos

use-cosmos:
@echo "Switching submodule to use cosmos/chain-registry"
git config submodule.packages/chain-registry/chain-registry.url https://github.com/cosmos/chain-registry
git submodule sync packages/chain-registry/chain-registry
git submodule update --init --remote packages/chain-registry/chain-registry
@echo "Submodule is now using cosmos/chain-registry"

use-fixtures:
@echo "Switching submodule to use cosmology-tech/chain-registry-fixtures"
git config submodule.packages/chain-registry/chain-registry.url https://github.com/cosmology-tech/chain-registry-fixtures
git submodule sync packages/chain-registry/chain-registry
git submodule update --init --remote packages/chain-registry/chain-registry
@echo "Submodule is now using cosmology-tech/chain-registry-fixtures"
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,29 @@ git commit -am "new registry updates"
lerna publish
```


### Switching Submodule Sources

Use the following Makefile commands to switch the submodule between the official repository and a testing fixtures repository:

- **use-cosmos**: Switches the submodule to use the official `cosmos/chain-registry` repository. Use this for standard development and production updates.

```
make use-cosmos
```

- **use-fixtures**: Switches the submodule to use the `cosmology-tech/chain-registry-fixtures` repository. This is useful for testing, allowing developers to work with stable test data, without syncing to random production data changes.

```
make use-fixtures
```

### When to Use Fixtures

Use the `use-fixtures` command when you need to test the system with controlled data.

⚠️ DO NOT COMMIT code that is using `use-fixtures`!

## Related

Checkout these related projects:
Expand Down
Loading

0 comments on commit 62c986b

Please sign in to comment.