diff --git a/.changeset/nice-chefs-deliver.md b/.changeset/nice-chefs-deliver.md new file mode 100644 index 0000000000..4b1496df69 --- /dev/null +++ b/.changeset/nice-chefs-deliver.md @@ -0,0 +1,5 @@ +--- +'@chainlink/token-balance-adapter': minor +--- + +testing workflow diff --git a/.changeset/tall-roses-peel.md b/.changeset/tall-roses-peel.md new file mode 100644 index 0000000000..e97a95e891 --- /dev/null +++ b/.changeset/tall-roses-peel.md @@ -0,0 +1,5 @@ +--- +'@chainlink/aleno-adapter': minor +--- + +testing workflow diff --git a/.github/scripts/create-release.sh b/.github/scripts/create-release.sh new file mode 100755 index 0000000000..16aad9e3e2 --- /dev/null +++ b/.github/scripts/create-release.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -euo pipefail + +args_to_ignore=() +args_adapters=() + +if [[ -n "${1:-}" ]]; then + eas_to_include="$(echo "$*" | sed -e 's/ *, */ /g' | tr ' ' '\n')" + packages_to_include="$(echo "$eas_to_include" | tr ' ' '\n' | sed -e 's|.*|@chainlink/&-adapter|')" + + all_packages=$(yarn workspaces list --json | jq -r '.name' | grep -v '@chainlink/external-adapters-js') + + args_to_ignore=($(echo "$all_packages" | grep -vFf <(echo "$packages_to_include" | tr ' ' '\n') | sed -e 's|^|--ignore |')) + args_adapters=($(echo "$eas_to_include" | tr ' ' '\n' | sed -e 's|^|--adapters &|')) +fi + +export UPSTREAM_BRANCH=main +yarn changeset version "${args_to_ignore[@]}" +yarn generate:master-list -v +yarn generate:readme -v "${args_adapters[*]}" +git add MASTERLIST.md "*README.md" +yarn lint-staged diff --git a/.github/scripts/packages-to-ignore.sh b/.github/scripts/packages-to-ignore.sh new file mode 100755 index 0000000000..9a0caa36fc --- /dev/null +++ b/.github/scripts/packages-to-ignore.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [[ -z "${1:-}" ]]; then + exit 0 +fi + +eas_to_include="$(echo "$*" | sed -e 's/ *, */ /g' | tr ' ' '\n')" +packages_to_include="$(echo "$eas_to_include" | tr ' ' '\n' | sed -e 's|.*|@chainlink/&-adapter|')" + +all_packages=$(yarn workspaces list --json | jq -r '.name' | grep -v '@chainlink/external-adapters-js') + +packages_to_ignore="$(echo "$all_packages" | grep -vFf <(echo "$packages_to_include" | tr ' ' '\n'))" + +echo "$packages_to_ignore" diff --git a/.github/scripts/run-changesets.sh b/.github/scripts/run-changesets.sh index 0b1503a32d..d12f676a76 100755 --- a/.github/scripts/run-changesets.sh +++ b/.github/scripts/run-changesets.sh @@ -1,7 +1,7 @@ #!/bin/bash -e # Run changesets -yarn changeset version +yarn changeset version "$@" # Recover all our changes (readmes, version bump) -git stash pop \ No newline at end of file +git stash pop diff --git a/.github/workflows/release-individual.yml b/.github/workflows/release-individual.yml new file mode 100644 index 0000000000..a0ba049f7e --- /dev/null +++ b/.github/workflows/release-individual.yml @@ -0,0 +1,102 @@ +name: Release individual adapters + +# Creates PRs in external-adapters-js and infra-k8s to release individually selected adapters. + +on: + workflow_dispatch: + inputs: + adapters: + description: Comma-separated list of adapter names to release + required: true + +jobs: + consume-changesets: + name: Upsert Release PR + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + UPSTREAM_BRANCH: 'main' + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + with: + # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits + fetch-depth: 0 + # We install only the changesets tool so we can do the mock changesets before installing dependencies, + # as the setup action will only build the files relevant to the changed adapters + - name: Install changesets tool + run: | + yarn add @changesets/cli@$(jq -r '.devDependencies."@changesets/cli"' package.json) + - name: Configure git + shell: bash + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + - name: Set CHANGESET_IGNORE_ARGS env var + run: | + CHANGESET_IGNORE_ARGS="$(.github/scripts/packages-to-ignore.sh ${{ github.event.inputs.adapters }} | sed -e 's/^/--ignore /' | tr '\n' ' ')" + echo "$CHANGESET_IGNORE_ARGS" + echo "CHANGESET_IGNORE_ARGS=$CHANGESET_IGNORE_ARGS" >> $GITHUB_ENV + cat $GITHUB_ENV + - name: Temporarily calculate changesets to generate readmes with proper versions + run: | + # Get from output of previous step: + PACKAGES_TO_IGNORE="${{ env.packages_to_ignore }}" + yarn changeset version $CHANGESET_IGNORE_ARGS + git add -A + git commit -m "Changesets mock" + - name: Set up and install dependencies + uses: ./.github/actions/setup + with: + build-all: 'true' + - name: Increase monorepo version + run: | + BUMPED_VERSION=$(jq -r '.version | split(".")[1] | tonumber | . + 1 | tostring | "1." + . + ".0"' package.json) + jq ".version = \"$BUMPED_VERSION\"" package.json > package.tmp.json + mv package.tmp.json package.json + echo "BUMPED_VERSION=$BUMPED_VERSION" >> $GITHUB_ENV + - name: Generate documentation + run: | + yarn generate:master-list -v + yarn generate:readme -v + - name: Undo temporary changesets and commit docs + run: | + git stash + git reset HEAD^ --hard + git stash pop + - name: Commit docs + run: | + git add MASTERLIST.md + git add "*README.md" + yarn lint-staged + - name: Stash changes for changesets action to pick up in custom script + run: | + git stash + - name: Create Release Pull Request + uses: smartcontractkit/.github/actions/signed-commits@4b7aa1d5b60f0d5704400a1d2b192905ad386e6c # changesets-signed-commits@1.2.4 + with: + # This version command is not only necessary because of yarn pnp, but because the changeset action + # performs git resets and we want to keep those changes, so we stash and then pop them here. + # All the previous steps would technically make more sense in the script itself, but we + # keep them as separate ones so it's easier to see them from the github UI to debug. + version: ./.github/scripts/run-changesets.sh ${{ env.CHANGESET_IGNORE_ARGS }} + title: 'testing Release ${{ env.BUMPED_VERSION }}' + commit: 'testing Release ${{ env.BUMPED_VERSION }}' + - name: Tag changesets commit + run: | + # Delete the tags if they already exist (ignore errors if they don't) + #git tag -d "v$BUMPED_VERSION" || true + #git push --delete origin "v$BUMPED_VERSION" || true + #git tag "v$BUMPED_VERSION" + #git push origin "v$BUMPED_VERSION" + # Because the workflows won't run and we technically don't need them for this autogenerated PR, + # we manually skip all the required checks by using the GitHub API directly. + - name: Skip required checks manually + run: | + COMMIT_SHA=$(git rev-parse HEAD) + ./.github/scripts/skip-check.sh $COMMIT_SHA "Adapter changes accompanied by a changeset" + ./.github/scripts/skip-check.sh $COMMIT_SHA "Documentation generation test" + ./.github/scripts/skip-check.sh $COMMIT_SHA "Install and verify dependencies" + ./.github/scripts/skip-check.sh $COMMIT_SHA "Run integration tests for changed adapters" + ./.github/scripts/skip-check.sh $COMMIT_SHA "Run linters and formatters" + ./.github/scripts/skip-check.sh $COMMIT_SHA "Run unit tests for changed adapters" diff --git a/.github/workflows/upsert-release-pr.yml b/.github/workflows/upsert-release-pr.yml index 55e210fff6..5d074f64fb 100644 --- a/.github/workflows/upsert-release-pr.yml +++ b/.github/workflows/upsert-release-pr.yml @@ -1,29 +1,13 @@ -name: Upsert Release PR +name: Upsert Release PR (testing individual release) + +# Creates PRs in external-adapters-js and infra-k8s to release individually selected adapters. on: - push: - branches: - - main - # The only commits that will contain changes to the masterlist will be releases - paths-ignore: - - 'MASTERLIST.md' - - 'package.json' - - '.changeset/**' - - 'packages/**/CHANGELOG.md' - - 'packages/**/README.md' - - 'packages/**/package.json' workflow_dispatch: inputs: - # For this workflow, BUILD_ALL will only affect the generate documentation step - build-all: - description: whether to run steps for all adapters, regardless of whether they were changed in this event - required: false - default: 'false' - -# TODO: This entire workflow would be immensely sped up (~3min -> 30s tops) if: -# - Readme generation did not require built TS files -# - Readme generation was optimized a bit -# - We only installed the changeset package + adapters: + description: Comma-separated list of adapter names to release + required: true jobs: consume-changesets: @@ -31,8 +15,7 @@ jobs: runs-on: ubuntu-latest env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - UPSTREAM_BRANCH: 'HEAD~1' - BUILD_ALL: ${{ github.event.inputs.build-all }} + UPSTREAM_BRANCH: 'main' steps: - name: Checkout Repo uses: actions/checkout@v4 @@ -49,16 +32,22 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" + - name: Set CHANGESET_IGNORE_ARGS env var + run: | + CHANGESET_IGNORE_ARGS="$(.github/scripts/packages-to-ignore.sh ${{ github.event.inputs.adapters }} | sed -e 's/^/--ignore /' | tr '\n' ' ')" + echo "$CHANGESET_IGNORE_ARGS" + echo "CHANGESET_IGNORE_ARGS=$CHANGESET_IGNORE_ARGS" >> $GITHUB_ENV + cat $GITHUB_ENV - name: Temporarily calculate changesets to generate readmes with proper versions run: | - yarn changeset version + # Get from output of previous step: + PACKAGES_TO_IGNORE="${{ env.packages_to_ignore }}" + yarn changeset version $CHANGESET_IGNORE_ARGS git add -A git commit -m "Changesets mock" - name: Set up and install dependencies uses: ./.github/actions/setup with: - base-branch: ${{ env.UPSTREAM_BRANCH }} - # We want to build all packages for the documentation generation step so that the Masterlist is up to date for all EAs build-all: 'true' - name: Increase monorepo version run: | @@ -83,6 +72,10 @@ jobs: - name: Stash changes for changesets action to pick up in custom script run: | git stash + - name: Choose a branch for the release PR + run: | + BRANCH_NAME=$(echo release-${{ github.event.inputs.adapters }} | tr ',' '-' | sed -e 's/[^a-zA-Z0-9]/-/g') + git checkout -b "$BRANCH_NAME" - name: Create Release Pull Request uses: smartcontractkit/.github/actions/signed-commits@4b7aa1d5b60f0d5704400a1d2b192905ad386e6c # changesets-signed-commits@1.2.4 with: @@ -90,16 +83,16 @@ jobs: # performs git resets and we want to keep those changes, so we stash and then pop them here. # All the previous steps would technically make more sense in the script itself, but we # keep them as separate ones so it's easier to see them from the github UI to debug. - version: ./.github/scripts/run-changesets.sh - title: 'Release ${{ env.BUMPED_VERSION }}' - commit: 'Release ${{ env.BUMPED_VERSION }}' + version: ./.github/scripts/run-changesets.sh ${{ env.CHANGESET_IGNORE_ARGS }} + title: 'testing Release ${{ env.BUMPED_VERSION }}' + commit: 'testing Release ${{ env.BUMPED_VERSION }}' - name: Tag changesets commit run: | # Delete the tags if they already exist (ignore errors if they don't) - git tag -d "v$BUMPED_VERSION" || true - git push --delete origin "v$BUMPED_VERSION" || true - git tag "v$BUMPED_VERSION" - git push origin "v$BUMPED_VERSION" + #git tag -d "v$BUMPED_VERSION" || true + #git push --delete origin "v$BUMPED_VERSION" || true + #git tag "v$BUMPED_VERSION" + #git push origin "v$BUMPED_VERSION" # Because the workflows won't run and we technically don't need them for this autogenerated PR, # we manually skip all the required checks by using the GitHub API directly. - name: Skip required checks manually diff --git a/.pnp.cjs b/.pnp.cjs index e8957f25e4..42f3fe795d 100644 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -6674,6 +6674,7 @@ const RAW_RUNTIME_STATE = ["command-line-args", "npm:5.2.1"],\ ["command-line-usage", "npm:6.1.3"],\ ["human-id", "npm:4.1.1"],\ + ["ini", "npm:5.0.0"],\ ["json-schema-ref-parser", "npm:9.0.9"],\ ["mockserver-client", "npm:5.11.2"],\ ["rxjs", "npm:7.4.0"],\ @@ -25823,6 +25824,13 @@ const RAW_RUNTIME_STATE = ["ini", "npm:2.0.0"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:5.0.0", {\ + "packageLocation": "./.yarn/cache/ini-npm-5.0.0-d1ec8350f4-76e5567b46.zip/node_modules/ini/",\ + "packageDependencies": [\ + ["ini", "npm:5.0.0"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["inquirer", [\ diff --git a/.yarn/cache/ini-npm-5.0.0-d1ec8350f4-76e5567b46.zip b/.yarn/cache/ini-npm-5.0.0-d1ec8350f4-76e5567b46.zip new file mode 100644 index 0000000000..8fcd15ec6c Binary files /dev/null and b/.yarn/cache/ini-npm-5.0.0-d1ec8350f4-76e5567b46.zip differ diff --git a/packages/scripts/package.json b/packages/scripts/package.json index 51e38f86c7..f27c423851 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -16,6 +16,7 @@ "class-validator": "0.14.2", "command-line-args": "5.2.1", "command-line-usage": "6.1.3", + "ini": "^5.0.0", "json-schema-ref-parser": "9.0.9", "mockserver-client": "5.11.2", "rxjs": "7.4.0", diff --git a/packages/scripts/src/create-release-prs/index.ts b/packages/scripts/src/create-release-prs/index.ts new file mode 100644 index 0000000000..1a1336388b --- /dev/null +++ b/packages/scripts/src/create-release-prs/index.ts @@ -0,0 +1,89 @@ +import { exec, test } from 'shelljs' +import * as fs from 'fs'; +import * as path from 'path'; +import * as ini from 'ini'; +import commandLineArgs from 'command-line-args' +import commandLineUsage from 'command-line-usage' +import { getWorkspaceAdapters } from '../workspace' + +export async function main(): Promise { + try { + // Define CLI options + const commandLineOptions = [ + { + name: 'adapters', + multiple: true, + defaultOption: true, + description: 'Adapters to include in release PRs', + }, + { name: 'help', alias: 'h', type: Boolean, description: 'Display usage guide' }, + ] + const options = commandLineArgs(commandLineOptions) + + // Generate usage guide + if (options.help) { + const usage = commandLineUsage([ + { + header: 'Release PR creation script', + content: + 'This script is run from the root of the external-adapter-js/ repo to create a PR in this repo and another PR in infra-k8s to facilitate the release of a subset of adapters.', + }, + { + header: 'Options', + optionList: commandLineOptions, + }, + { + content: + 'Source code: {underline https://github.com/smartcontractkit/external-adapters-\njs/packages/scripts/src/create-release-prs', + }, + ]) + console.log(usage) + return + } + + const allAdapters = getWorkspaceAdapters() + const adaptersToIgnore = [] + if (options.adapters && options.adapters.length > 0) { + adaptersToIgnore.push(...allAdapters.filter((a) => { + return !options.adapters.includes(a.descopedName) && !options.adapters.includes(a.descopedName.replace(/-adapter$/, '')) + })) + } + const ignoreArgs = adaptersToIgnore.map((a) => `--ignore ${a.name}`).join(' ') + + exec(`yarn changeset version ${ignoreArgs}`, { + fatal: true, + }) + + const awsConfigPath = path.join(process.env.HOME, '.aws', 'config') + const awsConfigText = fs.readFileSync(awsConfigPath).toString() + const awsConfig = ini.parse(awsConfigText) + const awsProfileSdlc = awsConfig['profile sdlc'] + + if (!awsProfileSdlc) { + throw new Error('AWS profile "sdlc" not found in ~/.aws/config') + } + + const sdlcAccountId = + + const imageRepo = + + console.log('dskloetx awsConfig', awsConfig['profile sdlc']) + + // gh workflow run --repo smartcontractkit/infra-k8s --ref main "Infra-k8s Image Dispatcher" -F imageRepos=795953128386.dkr.ecr.us-west-2.amazonaws.com/adapters/cmeth-adapter -F gitRepo=dskloet-test-fake-repo-name + + /* + const testOutput = exec(`yarn test ${this.integrationTestPath}`, { + fatal: true, + silent: true, + env: { ...process.env, ...testEnvOverrides }, + }).toString() + */ + + process.exit(0) + } catch (error) { + console.error({ error: error.message, stack: error.stack }) + process.exit(1) + } +} + +main() diff --git a/packages/sources/cmeth/CHANGELOG.md b/packages/sources/cmeth/CHANGELOG.md index 16d06c9a80..4d08e8104f 100644 --- a/packages/sources/cmeth/CHANGELOG.md +++ b/packages/sources/cmeth/CHANGELOG.md @@ -1,5 +1,11 @@ # @chainlink/cmeth-adapter +## 2.1.0 + +### Minor Changes + +- [`1816fb1`](https://github.com/smartcontractkit/external-adapters-js/commit/1816fb19e1cea0fabebd5c91adc292e4b4dc8ca4) Thanks [@dskloetc](https://github.com/dskloetc)! - testing workflow + ## 2.0.0 ### Major Changes diff --git a/packages/sources/cmeth/package.json b/packages/sources/cmeth/package.json index 6ae3ea6e48..1e4b58088f 100644 --- a/packages/sources/cmeth/package.json +++ b/packages/sources/cmeth/package.json @@ -1,6 +1,6 @@ { "name": "@chainlink/cmeth-adapter", - "version": "2.0.0", + "version": "2.1.0", "description": "Chainlink cmeth adapter.", "keywords": [ "Chainlink", diff --git a/yarn.lock b/yarn.lock index a33cda98d9..a1824f6c0e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3751,6 +3751,7 @@ __metadata: command-line-args: "npm:5.2.1" command-line-usage: "npm:6.1.3" human-id: "npm:4.1.1" + ini: "npm:^5.0.0" json-schema-ref-parser: "npm:9.0.9" mockserver-client: "npm:5.11.2" rxjs: "npm:7.4.0" @@ -20809,6 +20810,13 @@ __metadata: languageName: node linkType: hard +"ini@npm:^5.0.0": + version: 5.0.0 + resolution: "ini@npm:5.0.0" + checksum: 10/76e5567b46504b2b12650878ba6277204500a6ead3fe69eef419ee570456b364b39c040ee545846053f6d8a15797a82fc6d9efe06e392b9b6093935f4a2f2c30 + languageName: node + linkType: hard + "inquirer@npm:^1.0.2": version: 1.2.3 resolution: "inquirer@npm:1.2.3"