From 5ca99511360a16e3eb36d8d8bc03239e009927d2 Mon Sep 17 00:00:00 2001 From: Ze Date: Fri, 5 Jan 2024 09:56:21 -0800 Subject: [PATCH 1/3] Add back CI workflows (#11) * Add back CI workflows * Use environment to separate secrets * Update syntax * Add runs-on * Fix --- .github/workflows/build-and-test.yaml | 118 ++++++++++++++++++++++++++ .github/workflows/external-pr.yaml | 43 ++++++++++ .github/workflows/internal-pr.yaml | 41 +++++++++ 3 files changed, 202 insertions(+) create mode 100644 .github/workflows/build-and-test.yaml create mode 100644 .github/workflows/external-pr.yaml create mode 100644 .github/workflows/internal-pr.yaml diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml new file mode 100644 index 00000000..261005be --- /dev/null +++ b/.github/workflows/build-and-test.yaml @@ -0,0 +1,118 @@ +name: Build and Test + +on: + workflow_call: + inputs: + sha: + required: true + type: string + ENVIRONMENT: + required: true + type: string + secrets: + API_BASE_URL: + required: true + STORY_PROTOCOL_CONTRACT: + required: true + IP_ASSET_REGISTRY_CONTRACT: + required: true + IP_ORG_CONTROLLER_CONTRACT: + required: true + RELATIONSHIP_MODULE_CONTRACT: + required: true + REGISTRATION_MODULE_CONTRACT: + required: true + LICENSE_REGISTRY_CONTRACT: + required: true + MODULE_REGISTRY_CONTRACT: + required: true + LICENSE_MODULE_CONTRACT: + required: true + RPC_PROVIDER_URL: + required: true + WALLET_PRIVATE_KEY: + required: true + TEST_WALLET_ADDRESS: + required: true + TEST_IPORG_ID: + required: true + TEST_IPORG_ID_WITH_HOOK: + required: true + TEST_IPASSET_ID1: + required: true + TEST_IPASSET_ID2: + required: true + TEST_RELATIONSHIP_ID: + required: true + TEST_RELATIONSHIP_TYPE: + required: true + TEST_LICENSE_ID: + required: true + TEST_HOOK_ID: + required: true + TEST_MODULE_ID: + required: true + TEST_TRANSACTION_ID: + required: true + +jobs: + build: + name: Build and Test + timeout-minutes: 15 + runs-on: ubuntu-latest + ## Example to fix envrionment secret not passing in: https://github.com/AllanOricil/workflow-template-bug/blob/master/.github/workflows/workflow-template-fix-without-required-secret.yml + environment: ${{ inputs.ENVIRONMENT }} + env: + ## To use Remote Caching, uncomment the next lines and follow the steps below. + # TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + # TURBO_TEAM: ${{ vars.TURBO_TEAM }} + NEXT_PUBLIC_API_BASE_URL: ${{ secrets.API_BASE_URL }} + NEXT_PUBLIC_STORY_PROTOCOL_CONTRACT: ${{ secrets.STORY_PROTOCOL_CONTRACT }} + NEXT_PUBLIC_IP_ASSET_REGISTRY_CONTRACT: ${{ secrets.IP_ASSET_REGISTRY_CONTRACT }} + NEXT_PUBLIC_IP_ORG_CONTROLLER_CONTRACT: ${{ secrets.IP_ORG_CONTROLLER_CONTRACT }} + NEXT_PUBLIC_RELATIONSHIP_MODULE_CONTRACT: ${{ secrets.RELATIONSHIP_MODULE_CONTRACT }} + NEXT_PUBLIC_REGISTRATION_MODULE_CONTRACT: ${{ secrets.REGISTRATION_MODULE_CONTRACT }} + NEXT_PUBLIC_LICENSE_REGISTRY_CONTRACT: ${{ secrets.LICENSE_REGISTRY_CONTRACT }} + NEXT_PUBLIC_MODULE_REGISTRY_CONTRACT: ${{ secrets.MODULE_REGISTRY_CONTRACT }} + NEXT_PUBLIC_LICENSE_MODULE_CONTRACT: ${{secrets.LICENSE_MODULE_CONTRACT}} + RPC_PROVIDER_URL: ${{ secrets.RPC_PROVIDER_URL }} + WALLET_PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }} + TEST_WALLET_ADDRESS: ${{ secrets.TEST_WALLET_ADDRESS }} + TEST_IPORG_ID: ${{ secrets.TEST_IPORG_ID }} + TEST_IPORG_ID_WITH_HOOK: ${{ secrets.TEST_IPORG_ID_WITH_HOOK }} + TEST_IPASSET_ID1: ${{ secrets.TEST_IPASSET_ID1 }} + TEST_IPASSET_ID2: ${{ secrets.TEST_IPASSET_ID2 }} + TEST_RELATIONSHIP_ID: ${{ secrets.TEST_RELATIONSHIP_ID }} + TEST_RELATIONSHIP_TYPE: ${{ secrets.TEST_RELATIONSHIP_TYPE }} + TEST_LICENSE_ID: ${{ secrets.TEST_LICENSE_ID }} + TEST_HOOK_ID: ${{ secrets.TEST_HOOK_ID }} + TEST_MODULE_ID: ${{ secrets.TEST_MODULE_ID }} + TEST_TRANSACTION_ID: ${{ secrets.TEST_TRANSACTION_ID }} + + steps: + - name: Check out code + uses: actions/checkout@v3 + with: + ref: ${{ inputs.sha }} + + - uses: pnpm/action-setup@v2.0.1 + with: + version: 8.8.0 + + - name: Setup Node.js environment + uses: actions/setup-node@v3 + with: + node-version: 20.0.0 + cache: pnpm + + - name: Install dependencies + run: pnpm install + + - name: Fix + run: pnpm fix + + - name: Test + run: pnpm test + + - name: Build + run: pnpm build \ No newline at end of file diff --git a/.github/workflows/external-pr.yaml b/.github/workflows/external-pr.yaml new file mode 100644 index 00000000..757983d8 --- /dev/null +++ b/.github/workflows/external-pr.yaml @@ -0,0 +1,43 @@ +name: External PR + +on: + pull_request_target: + types: [opened, synchronize] + +jobs: + authorize: + if: github.event.pull_request.head.repo.full_name != github.repository + environment: 'external' + runs-on: ubuntu-latest + steps: + - run: true + build_and_test: + needs: authorize + uses: ./.github/workflows/build-and-test.yaml + with: + sha: ${{ github.event.pull_request.head.sha }} + ENVIRONMENT: 'alpha-sepolia' + secrets: + API_BASE_URL: ${{ secrets.API_BASE_URL }} + STORY_PROTOCOL_CONTRACT: ${{ secrets.STORY_PROTOCOL_CONTRACT }} + IP_ASSET_REGISTRY_CONTRACT: ${{ secrets.IP_ASSET_REGISTRY_CONTRACT }} + IP_ORG_CONTROLLER_CONTRACT: ${{ secrets.IP_ORG_CONTROLLER_CONTRACT }} + RELATIONSHIP_MODULE_CONTRACT: ${{ secrets.RELATIONSHIP_MODULE_CONTRACT }} + REGISTRATION_MODULE_CONTRACT: ${{ secrets.REGISTRATION_MODULE_CONTRACT }} + LICENSE_REGISTRY_CONTRACT: ${{ secrets.LICENSE_REGISTRY_CONTRACT }} + MODULE_REGISTRY_CONTRACT: ${{ secrets.MODULE_REGISTRY_CONTRACT }} + LICENSE_MODULE_CONTRACT: ${{ secrets.LICENSE_MODULE_CONTRACT }} + RPC_PROVIDER_URL: ${{ secrets.RPC_PROVIDER_URL }} + WALLET_PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }} + TEST_WALLET_ADDRESS: ${{ secrets.TEST_WALLET_ADDRESS }} + TEST_IPORG_ID: ${{ secrets.TEST_IPORG_ID }} + TEST_IPORG_ID_WITH_HOOK: ${{ secrets.TEST_IPORG_ID_WITH_HOOK }} + TEST_IPASSET_ID1: ${{ secrets.TEST_IPASSET_ID1 }} + TEST_IPASSET_ID2: ${{ secrets.TEST_IPASSET_ID2 }} + TEST_RELATIONSHIP_ID: ${{ secrets.TEST_RELATIONSHIP_ID }} + TEST_RELATIONSHIP_TYPE: ${{ secrets.TEST_RELATIONSHIP_TYPE }} + TEST_LICENSE_ID: ${{ secrets.TEST_LICENSE_ID }} + TEST_HOOK_ID: ${{ secrets.TEST_HOOK_ID }} + TEST_MODULE_ID: ${{ secrets.TEST_MODULE_ID }} + TEST_TRANSACTION_ID: ${{ secrets.TEST_TRANSACTION_ID }} + \ No newline at end of file diff --git a/.github/workflows/internal-pr.yaml b/.github/workflows/internal-pr.yaml new file mode 100644 index 00000000..bc93d2f1 --- /dev/null +++ b/.github/workflows/internal-pr.yaml @@ -0,0 +1,41 @@ +name: Internal PR + +on: + push: + branches: + - main + - dev + pull_request: + branches: + - main + - dev + +jobs: + build_and_test: + uses: ./.github/workflows/build-and-test.yaml + with: + sha: ${{ github.event.pull_request.head.sha }} + ENVIRONMENT: 'alpha-sepolia' + secrets: + API_BASE_URL: ${{ secrets.API_BASE_URL }} + STORY_PROTOCOL_CONTRACT: ${{ secrets.STORY_PROTOCOL_CONTRACT }} + IP_ASSET_REGISTRY_CONTRACT: ${{ secrets.IP_ASSET_REGISTRY_CONTRACT }} + IP_ORG_CONTROLLER_CONTRACT: ${{ secrets.IP_ORG_CONTROLLER_CONTRACT }} + RELATIONSHIP_MODULE_CONTRACT: ${{ secrets.RELATIONSHIP_MODULE_CONTRACT }} + REGISTRATION_MODULE_CONTRACT: ${{ secrets.REGISTRATION_MODULE_CONTRACT }} + LICENSE_REGISTRY_CONTRACT: ${{ secrets.LICENSE_REGISTRY_CONTRACT }} + MODULE_REGISTRY_CONTRACT: ${{ secrets.MODULE_REGISTRY_CONTRACT }} + LICENSE_MODULE_CONTRACT: ${{ secrets.LICENSE_MODULE_CONTRACT }} + RPC_PROVIDER_URL: ${{ secrets.RPC_PROVIDER_URL }} + WALLET_PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }} + TEST_WALLET_ADDRESS: ${{ secrets.TEST_WALLET_ADDRESS }} + TEST_IPORG_ID: ${{ secrets.TEST_IPORG_ID }} + TEST_IPORG_ID_WITH_HOOK: ${{ secrets.TEST_IPORG_ID_WITH_HOOK }} + TEST_IPASSET_ID1: ${{ secrets.TEST_IPASSET_ID1 }} + TEST_IPASSET_ID2: ${{ secrets.TEST_IPASSET_ID2 }} + TEST_RELATIONSHIP_ID: ${{ secrets.TEST_RELATIONSHIP_ID }} + TEST_RELATIONSHIP_TYPE: ${{ secrets.TEST_RELATIONSHIP_TYPE }} + TEST_LICENSE_ID: ${{ secrets.TEST_LICENSE_ID }} + TEST_HOOK_ID: ${{ secrets.TEST_HOOK_ID }} + TEST_MODULE_ID: ${{ secrets.TEST_MODULE_ID }} + TEST_TRANSACTION_ID: ${{ secrets.TEST_TRANSACTION_ID }} From fb893a1605bb24f973e0020897b6a86dfbdd48eb Mon Sep 17 00:00:00 2001 From: Andy Wu Date: Thu, 18 Jan 2024 10:54:29 -0800 Subject: [PATCH 2/3] [test] bump up version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3eaf1593..7b6c980a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typescript-sdk", - "version": "0.0.0", + "version": "0.0.1", "private": true, "repository": "https://github.com/storyprotocol/typescript-sdk", "author": "storyprotocol engineering ", From 75e527550ee03bdc20fc8b5f5cdf8ac18347ac67 Mon Sep 17 00:00:00 2001 From: Andy Wu Date: Thu, 18 Jan 2024 10:57:52 -0800 Subject: [PATCH 3/3] [test] remove external-pr.yaml --- .github/workflows/external-pr.yaml | 43 ------------------------------ 1 file changed, 43 deletions(-) delete mode 100644 .github/workflows/external-pr.yaml diff --git a/.github/workflows/external-pr.yaml b/.github/workflows/external-pr.yaml deleted file mode 100644 index 757983d8..00000000 --- a/.github/workflows/external-pr.yaml +++ /dev/null @@ -1,43 +0,0 @@ -name: External PR - -on: - pull_request_target: - types: [opened, synchronize] - -jobs: - authorize: - if: github.event.pull_request.head.repo.full_name != github.repository - environment: 'external' - runs-on: ubuntu-latest - steps: - - run: true - build_and_test: - needs: authorize - uses: ./.github/workflows/build-and-test.yaml - with: - sha: ${{ github.event.pull_request.head.sha }} - ENVIRONMENT: 'alpha-sepolia' - secrets: - API_BASE_URL: ${{ secrets.API_BASE_URL }} - STORY_PROTOCOL_CONTRACT: ${{ secrets.STORY_PROTOCOL_CONTRACT }} - IP_ASSET_REGISTRY_CONTRACT: ${{ secrets.IP_ASSET_REGISTRY_CONTRACT }} - IP_ORG_CONTROLLER_CONTRACT: ${{ secrets.IP_ORG_CONTROLLER_CONTRACT }} - RELATIONSHIP_MODULE_CONTRACT: ${{ secrets.RELATIONSHIP_MODULE_CONTRACT }} - REGISTRATION_MODULE_CONTRACT: ${{ secrets.REGISTRATION_MODULE_CONTRACT }} - LICENSE_REGISTRY_CONTRACT: ${{ secrets.LICENSE_REGISTRY_CONTRACT }} - MODULE_REGISTRY_CONTRACT: ${{ secrets.MODULE_REGISTRY_CONTRACT }} - LICENSE_MODULE_CONTRACT: ${{ secrets.LICENSE_MODULE_CONTRACT }} - RPC_PROVIDER_URL: ${{ secrets.RPC_PROVIDER_URL }} - WALLET_PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }} - TEST_WALLET_ADDRESS: ${{ secrets.TEST_WALLET_ADDRESS }} - TEST_IPORG_ID: ${{ secrets.TEST_IPORG_ID }} - TEST_IPORG_ID_WITH_HOOK: ${{ secrets.TEST_IPORG_ID_WITH_HOOK }} - TEST_IPASSET_ID1: ${{ secrets.TEST_IPASSET_ID1 }} - TEST_IPASSET_ID2: ${{ secrets.TEST_IPASSET_ID2 }} - TEST_RELATIONSHIP_ID: ${{ secrets.TEST_RELATIONSHIP_ID }} - TEST_RELATIONSHIP_TYPE: ${{ secrets.TEST_RELATIONSHIP_TYPE }} - TEST_LICENSE_ID: ${{ secrets.TEST_LICENSE_ID }} - TEST_HOOK_ID: ${{ secrets.TEST_HOOK_ID }} - TEST_MODULE_ID: ${{ secrets.TEST_MODULE_ID }} - TEST_TRANSACTION_ID: ${{ secrets.TEST_TRANSACTION_ID }} - \ No newline at end of file