diff --git a/.github/workflows/checkout.yml b/.github/workflows/checkout.yml new file mode 100644 index 00000000000..e243030602b --- /dev/null +++ b/.github/workflows/checkout.yml @@ -0,0 +1,11 @@ +on: + workflow_call: + secrets: inherit + +jobs: + checkout: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 0ffab92e7e4..c3b5d02fe45 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -18,49 +18,22 @@ env: TURBO_TEAM: ${{ secrets.TURBO_TEAM }} jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 + checkout: + uses: ./.github/workflows/checkout.yml@main - - name: Install package manager - uses: pnpm/action-setup@v2 - with: - version: 8.6.1 - - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: 'pnpm' + install-dependencies: + uses: ./.github/workflows/install-dependencies.yml@main - - name: Install dependencies - run: pnpm install - - - name: Get Test Validator Latest Release - id: get-test-validator-version - run: | - echo "version=$(./scripts/get-latest-validator-release-version.sh)" >> $GITHUB_OUTPUT - shell: bash - - - name: Cache Test Validator - id: cache-test-validator - uses: actions/cache@v3 - with: - path: .solana - key: ${{ runner.os }}-test-validator-${{ steps.get-test-validator-version.outputs.version }} - - - name: Install Test Validator - if: steps.cache-test-validator.outputs.cache-hit != 'true' - run: scripts/setup-test-validator.sh - - - name: Start Test Validator - id: test-validator - run: | - ./scripts/start-shared-test-validator.sh & - echo "TEST_VALIDATOR_PID=$!" >> "$GITHUB_OUTPUT" + setup-validator: + uses: ./.github/workflows/validator-setup.yml@main + build-and-publish-to-npm: + needs: + - checkout + - install-dependencies + - setup-validator + runs-on: ubuntu-latest + steps: - name: Publish NPM run: | pnpm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" @@ -69,11 +42,16 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Stop Test Validator - run: kill ${{ steps.test-validator.outputs.TEST_VALIDATOR_PID}} - + deploy-docs: + needs: build-and-publish-to-npm + steps: - name: Deploy Github Page uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./packages/library-legacy/doc + + validator_teardown: + uses: ./.github/workflows/validator-teardown.yml@main + needs: build-and-publish-to-npm + if: always() diff --git a/.github/workflows/install-dependencies.yml b/.github/workflows/install-dependencies.yml new file mode 100644 index 00000000000..906abd95076 --- /dev/null +++ b/.github/workflows/install-dependencies.yml @@ -0,0 +1,26 @@ +on: + workflow_call: + secrets: inherit + +jobs: + checkout: + uses: ./.github/workflows/checkout.yml@main + + install-dependencies: + needs: checkout + runs-on: ubuntu-latest + + steps: + - name: Install package manager + uses: pnpm/action-setup@v2 + with: + version: 8.6.1 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index c782301053b..1fcf79a928b 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -16,13 +16,25 @@ jobs: # Needed for grouping check-web3 strategies into one check for mergify all-web3-checks: runs-on: ubuntu-latest - needs: - - build-and-test + needs: build-and-test steps: - run: echo "Done" + checkout: + uses: ./.github/workflows/checkout.yml@main + + install-dependencies: + uses: ./.github/workflows/install-dependencies.yml@main + + setup-validator: + uses: ./.github/workflows/validator-setup.yml@main + build-and-test: runs-on: ubuntu-latest + needs: + - checkout + - install-dependencies + - setup-validator strategy: matrix: @@ -32,52 +44,12 @@ jobs: name: Build & Test on Node ${{ matrix.node }} steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install package manager - uses: pnpm/action-setup@v2 - with: - version: 8.6.1 - - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node }} - cache: 'pnpm' - - - name: Install dependencies - run: pnpm install - - - name: Get Test Validator Latest Release - id: get-test-validator-version - run: | - echo "version=$(./scripts/get-latest-validator-release-version.sh)" >> $GITHUB_OUTPUT - shell: bash - - - name: Cache Test Validator - id: cache-test-validator - uses: actions/cache@v3 - with: - path: .solana - key: ${{ runner.os }}-test-validator-${{ steps.get-test-validator-version.outputs.version }} - - - name: Install Test Validator - if: steps.cache-test-validator.outputs.cache-hit != 'true' - run: scripts/setup-test-validator.sh - - - name: Start Test Validator - id: test-validator - run: | - ./scripts/start-shared-test-validator.sh & - echo "TEST_VALIDATOR_PID=$!" >> "$GITHUB_OUTPUT" - - name: Build & Test run: pnpm build --concurrency=100% - - name: Stop Test Validator - run: kill ${{ steps.test-validator.outputs.TEST_VALIDATOR_PID}} - + upload-build-artifacts: + needs: build-and-test + steps: - name: Upload Experimental library build artifacts if: matrix.node == 'current' uses: actions/upload-artifact@v3 @@ -86,3 +58,8 @@ jobs: path: | ./packages/library/dist/ ./packages/library/package.json + + validator_teardown: + uses: ./.github/workflows/validator-teardown.yml@main + needs: build-and-test + if: always() diff --git a/.github/workflows/validator-setup.yml b/.github/workflows/validator-setup.yml new file mode 100644 index 00000000000..2c87d57b480 --- /dev/null +++ b/.github/workflows/validator-setup.yml @@ -0,0 +1,42 @@ +on: + workflow_call: + outputs: + pid: + description: The PID of the running test validator + value: ${{ jobs.setup-validator.outputs.pid }} + secrets: inherit + +jobs: + checkout: + uses: ./.github/workflows/checkout.yml@main + + setup-validator: + needs: checkout + name: Install & Start Test Validator + runs-on: ubuntu-latest + + outputs: + pid: ${{ steps.test-validator.outputs.TEST_VALIDATOR_PID }} + + steps: + - name: Get Test Validator Latest Release + id: get-test-validator-version + run: echo "version=$(./scripts/get-latest-validator-release-version.sh)" >> $GITHUB_OUTPUT + shell: bash + + - name: Cache Test Validator + id: cache-test-validator + uses: actions/cache@v3 + with: + path: .solana + key: ${{ runner.os }}-test-validator-${{ steps.get-test-validator-version.outputs.version }} + + - name: Install Test Validator + if: steps.cache-test-validator.outputs.cache-hit != 'true' + run: scripts/setup-test-validator.sh + + - name: Start Test Validator + id: test-validator + run: | + ./scripts/start-shared-test-validator.sh & + echo "TEST_VALIDATOR_PID=$!" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/validator-teardown.yml b/.github/workflows/validator-teardown.yml new file mode 100644 index 00000000000..150640cd57d --- /dev/null +++ b/.github/workflows/validator-teardown.yml @@ -0,0 +1,16 @@ +on: + workflow_call: + inputs: + pid: + required: true + type: string + secrets: inherit + +jobs: + teardown_validator: + name: Stop Test Validator + runs-on: ubuntu-latest + + steps: + - name: Stop Test Validator + run: kill ${{ inputs.pid }}