diff --git a/.github/workflows/chaos.yml b/.github/workflows/chaos.yml index 26c947a1f..479c05514 100644 --- a/.github/workflows/chaos.yml +++ b/.github/workflows/chaos.yml @@ -1,4 +1,4 @@ -name: chaos +name: e2e_chaos_tests on: schedule: - cron: '0 */3 * * *' @@ -11,31 +11,31 @@ on: type: string jobs: - build: + chaos_testing_build_contracts: + name: Chaos Testing Build Contracts runs-on: ubuntu-latest container: image: projectserum/build:v0.22.1 env: RUSTUP_HOME: "/root/.rustup" FORCE_COLOR: 1 - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} steps: - uses: actions/checkout@v2 - run: echo $HOME - run: echo $PATH - - run: | - npm config set -- '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" - NPM_TOKEN=${NPM_TOKEN} yarn install --frozen-lockfile + - run: yarn install --frozen-lockfile - name: Generate program_ids run: ./scripts/programs-keys-gen.sh - - run: anchor build + - name: Build Contracts + run: anchor build working-directory: contracts - - uses: actions/upload-artifact@master + - name: Upload Artifacts + uses: actions/upload-artifact@master with: name: target path: contracts/target/deploy - build_custom_cl_image: - name: Build custom CL image + chaos_testing_build_custom_chainlink_image: + name: Chaos Testing Build Custom Chainlink Image # target branch can't be set as var, it's from where we getting pipeline code uses: smartcontractkit/chainlink/.github/workflows/build-custom.yml@develop with: @@ -50,18 +50,24 @@ jobs: AWS_REGION: ${{ secrets.QA_AWS_REGION }} AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }} QA_KUBECONFIG: ${{ secrets.QA_KUBECONFIG }} - chaos: + chaos_testing_run_test: + name: Chaos Testing Run Test runs-on: ubuntu-latest - needs: [build, build_custom_cl_image] + needs: [chaos_testing_build_contracts, chaos_testing_build_custom_chainlink_image] env: CGO_ENABLED: 1 steps: - name: Checkout the repo uses: actions/checkout@v2 - - name: Setup go - uses: actions/setup-go@v1 + - name: .tool-versions to .env + run: ./scripts/tool-versions-to-env.sh + - name: dotenv + uses: falti/dotenv-action@v0.2.7 + id: dotenv + - name: Setup go ${{ steps.dotenv.outputs.golang_version }} + uses: actions/setup-go@v2 with: - go-version: 1.17 + go-version: ${{ steps.dotenv.outputs.golang_version }} - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v1 with: @@ -94,7 +100,8 @@ jobs: go get github.com/onsi/ginkgo/v2/ginkgo/internal@v2.1.2 go get github.com/onsi/ginkgo/v2/ginkgo/labels@v2.1.2 go install github.com/onsi/ginkgo/v2/ginkgo - - uses: actions/download-artifact@master + - name: Download Artifacts + uses: actions/download-artifact@master with: name: target path: contracts/target/deploy diff --git a/.github/workflows/contract-release.yml b/.github/workflows/contract-release.yml index 90fa297ab..5843499be 100644 --- a/.github/workflows/contract-release.yml +++ b/.github/workflows/contract-release.yml @@ -1,4 +1,4 @@ -name: Release Artifacts +name: release_artifacts on: push: tags: @@ -10,6 +10,7 @@ defaults: working-directory: ./contracts jobs: release-artifacts: + name: Release Artifacts runs-on: ubuntu-latest container: image: projectserum/build:v0.22.1 diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 267ea209b..b7ff0c9f1 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -1,4 +1,4 @@ -name: e2e_workflow_call +name: e2e_smoke_tests on: workflow_call: inputs: @@ -31,44 +31,49 @@ on: required: true jobs: - build: + e2e_build_contracts: + name: E2E Build Contracts runs-on: ubuntu-latest container: image: projectserum/build:v0.22.1 env: RUSTUP_HOME: "/root/.rustup" FORCE_COLOR: 1 - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} steps: - uses: actions/checkout@v2 with: repository: ${{ inputs.repo_name }} - run: echo $HOME - run: echo $PATH - - run: | - npm config set -- '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" - NPM_TOKEN=${NPM_TOKEN} yarn install --frozen-lockfile + - run: yarn install --frozen-lockfile - name: Generate program_ids run: ./scripts/programs-keys-gen.sh - run: anchor build working-directory: contracts - - uses: actions/upload-artifact@master + - name: Upload Artifacts + uses: actions/upload-artifact@master with: name: target path: contracts/target/deploy - smoke: + e2e_run_smoke_tests: + name: E2E Run Smoke Tests runs-on: ubuntu-latest - needs: build + needs: e2e_build_contracts steps: - name: Checkout the repo uses: actions/checkout@v2 with: repository: ${{ inputs.repo_name }} ref: ${{ inputs.ref }} - - name: Setup go - uses: actions/setup-go@v1 + - name: .tool-versions to .env + run: ./scripts/tool-versions-to-env.sh + - name: dotenv + uses: falti/dotenv-action@v0.2.7 + id: dotenv + - name: Setup go ${{ steps.dotenv.outputs.golang_version }} + uses: actions/setup-go@v2 with: - go-version: 1.17 + go-version: ${{ steps.dotenv.outputs.golang_version }} - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v1 with: @@ -89,19 +94,22 @@ jobs: path: | ~/.cache/go-build ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + ~/go/bin + key: ${{ runner.os }}-go2-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-go- + ${{ runner.os }}-go2- - name: Download Go Vendor Packages if: steps.cache-packages.outputs.cache-hit != 'true' - run: go mod download + run: make download - name: Install Ginkgo CLI + if: steps.cache-packages.outputs.cache-hit != 'true' + run: | + make install + - name: Check for ginkgo ls run: | - go get github.com/onsi/ginkgo/v2/ginkgo/generators@v2.1.2 - go get github.com/onsi/ginkgo/v2/ginkgo/internal@v2.1.2 - go get github.com/onsi/ginkgo/v2/ginkgo/labels@v2.1.2 - go install github.com/onsi/ginkgo/v2/ginkgo - - uses: actions/download-artifact@master + ls ~/go/bin/ + - name: Download Artifacts + uses: actions/download-artifact@master with: name: target path: contracts/target/deploy @@ -117,7 +125,7 @@ jobs: CGO_ENABLED: 1 run: | export PATH=$PATH:$(go env GOPATH)/bin - ginkgo tests/e2e/smoke + make test_smoke - name: Publish Test Results uses: mikepenz/action-junit-report@v2 if: always() diff --git a/.github/workflows/e2e_custom_cl.yml b/.github/workflows/e2e_custom_cl.yml index dcac89395..e4f771ee1 100644 --- a/.github/workflows/e2e_custom_cl.yml +++ b/.github/workflows/e2e_custom_cl.yml @@ -1,4 +1,4 @@ -name: e2e_tests_custom_cl_image +name: e2e_tests_custom_cl on: push: workflow_dispatch: @@ -9,33 +9,33 @@ on: default: develop type: string jobs: - build: + + e2e_custom_build_artifacts: + name: E2E Custom Build Artifacts runs-on: ubuntu-latest container: image: projectserum/build:v0.22.1 env: RUSTUP_HOME: "/root/.rustup" FORCE_COLOR: 1 - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} steps: - uses: actions/checkout@v2 with: repository: ${{ inputs.repo_name }} - run: echo $HOME - run: echo $PATH - - run: | - npm config set -- '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" - NPM_TOKEN=${NPM_TOKEN} yarn install --frozen-lockfile + - run: yarn install --frozen-lockfile - name: Generate program_ids run: ./scripts/programs-keys-gen.sh - run: anchor build working-directory: contracts - - uses: actions/upload-artifact@master + - name: Upload Artifacts + uses: actions/upload-artifact@master with: name: target path: contracts/target/deploy - build_custom_cl_image: - name: Build custom CL image + e2e_custom_build_custom_chainlink_image: + name: E2E Custom Build Custom CL Image # target branch can't be set as var, it's from where we getting pipeline code uses: smartcontractkit/chainlink/.github/workflows/build-custom.yml@develop with: @@ -50,18 +50,22 @@ jobs: AWS_REGION: ${{ secrets.QA_AWS_REGION }} AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }} QA_KUBECONFIG: ${{ secrets.QA_KUBECONFIG }} - smoke: + e2e_custom_run_smoke_tests: + name: E2E Custom Run Smoke Tests runs-on: ubuntu-latest - needs: [build, build_custom_cl_image] + needs: [e2e_custom_build_artifacts, e2e_custom_build_custom_chainlink_image] steps: - name: Checkout the repo uses: actions/checkout@v2 - - name: go version - run: go version - - name: Setup go - uses: actions/setup-go@v1 + - name: .tool-versions to .env + run: ./scripts/tool-versions-to-env.sh + - name: dotenv + uses: falti/dotenv-action@v0.2.7 + id: dotenv + - name: Setup go ${{ steps.dotenv.outputs.golang_version }} + uses: actions/setup-go@v2 with: - go-version: 1.17.2 + go-version: ${{ steps.dotenv.outputs.golang_version }} - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v1 with: @@ -82,19 +86,22 @@ jobs: path: | ~/.cache/go-build ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + ~/go/bin + key: ${{ runner.os }}-go2-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-go- + ${{ runner.os }}-go2- - name: Download Go Vendor Packages if: steps.cache-packages.outputs.cache-hit != 'true' - run: go mod download + run: make download - name: Install Ginkgo CLI + if: steps.cache-packages.outputs.cache-hit != 'true' + run: | + make install + - name: Check for ginkgo ls run: | - go get github.com/onsi/ginkgo/v2/ginkgo/generators@v2.1.2 - go get github.com/onsi/ginkgo/v2/ginkgo/internal@v2.1.2 - go get github.com/onsi/ginkgo/v2/ginkgo/labels@v2.1.2 - go install github.com/onsi/ginkgo/v2/ginkgo - - uses: actions/download-artifact@master + ls ~/go/bin/ + - name: Download Artifacts + uses: actions/download-artifact@master with: name: target path: contracts/target/deploy @@ -108,7 +115,7 @@ jobs: CGO_ENABLED: 1 run: | export PATH=$PATH:$(go env GOPATH)/bin - ginkgo tests/e2e/smoke + make test_smoke - name: Publish Test Results uses: mikepenz/action-junit-report@v2 if: always() diff --git a/.github/workflows/gauntlet.yml b/.github/workflows/gauntlet.yml index 68e390633..f9469b183 100644 --- a/.github/workflows/gauntlet.yml +++ b/.github/workflows/gauntlet.yml @@ -1,80 +1,64 @@ -name: Gauntlet +name: gauntlet on: push: jobs: - build: - strategy: - matrix: - platform: [ubuntu-latest] - node-version: [14.x] - env: - CI: true - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - runs-on: ${{ matrix.platform }} - + gauntlet_build: + name: Gauntlet Build + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + - name: .tool-versions to .env + run: ./scripts/tool-versions-to-env.sh + - name: dotenv + uses: falti/dotenv-action@v0.2.7 + id: dotenv + - name: Setup Node ${{ steps.dotenv.outputs.nodejs_version }} + uses: actions/setup-node@v2 with: - node-version: ${{ matrix.node-version }} - - run: | - npm config set -- '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" - cd gauntlet - ${{ matrix.env }} yarn install - - run: | - cd gauntlet - ${{ matrix.env }} yarn build - - run: | - cd gauntlet - ${{ matrix.env }} yarn gauntlet - - format: - strategy: - matrix: - platform: [ubuntu-latest] - node-version: [14.x] - env: - CI: true - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - runs-on: ${{ matrix.platform }} + node-version: ${{ steps.dotenv.outputs.nodejs_version }} + - name: Install + run: yarn --cwd ./gauntlet install --frozen-lockfile + - name: Build + run: yarn --cwd ./gauntlet build + - name: Run Gauntlet + run: yarn --cwd ./gauntlet gauntlet + gauntlet_format: + name: Gauntlet Format + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + - name: .tool-versions to .env + run: ./scripts/tool-versions-to-env.sh + - name: dotenv + uses: falti/dotenv-action@v0.2.7 + id: dotenv + - name: Setup Node ${{ steps.dotenv.outputs.nodejs_version }} + uses: actions/setup-node@v2 with: - node-version: ${{ matrix.node-version }} - - run: | - npm config set -- '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" - cd gauntlet - ${{ matrix.env }} yarn install - - run: | - cd gauntlet - ${{ matrix.env }} yarn lint:format - - test: - strategy: - matrix: - platform: [ubuntu-latest] - node-version: [14.x] - env: - CI: true - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - runs-on: ${{ matrix.platform }} + node-version: ${{ steps.dotenv.outputs.nodejs_version }} + - name: Install + run: yarn --cwd ./gauntlet install --frozen-lockfile + - name: Lint + run: yarn --cwd ./gauntlet lint:format + gauntlet_run_tests: + name: Gauntlet Run Tests + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + - name: .tool-versions to .env + run: ./scripts/tool-versions-to-env.sh + - name: dotenv + uses: falti/dotenv-action@v0.2.7 + id: dotenv + - name: Setup Node ${{ steps.dotenv.outputs.nodejs_version }} + uses: actions/setup-node@v2 with: - node-version: ${{ matrix.node-version }} - - run: | - npm config set -- '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" - cd gauntlet - ${{ matrix.env }} yarn install - - run: | - cd gauntlet - ${{ matrix.env }} yarn test:ci + node-version: ${{ steps.dotenv.outputs.nodejs_version }} + - name: Install + run: yarn --cwd ./gauntlet install --frozen-lockfile + - name: test:ci + run: yarn --cwd ./gauntlet test:ci diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 000000000..d6a70e032 --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,35 @@ +name: golangci_lint + +on: + push: + +jobs: + golang_lint: + name: Golang Lint + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 + with: + # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version + version: v1.43.0 + + # Optional: working directory, useful for monorepos + # working-directory: somedir + + # Optional: golangci-lint command line arguments. + args: --enable=gofmt --tests=false --exclude-use-default --timeout=5m0s + + # Optional: show only new issues if it's a pull request. The default value is `false`. + only-new-issues: true + + # Optional: if set to true then the action will use pre-installed Go. + # skip-go-installation: true + + # Optional: if set to true then the action don't cache or restore ~/go/pkg. + # skip-pkg-cache: true + + # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. + # skip-build-cache: true diff --git a/.github/workflows/relay.yml b/.github/workflows/relay.yml index c7e4eec90..859434bbb 100644 --- a/.github/workflows/relay.yml +++ b/.github/workflows/relay.yml @@ -1,20 +1,24 @@ -name: Relay +name: relay on: push: - branches: - - main - pull_request: jobs: - test: + relay_run_unit_tests: + name: Relay Run Unit Tests runs-on: ubuntu-latest steps: - name: Checkout sources uses: actions/checkout@v2 - - uses: actions/setup-go@v1 + - name: .tool-versions to .env + run: ./scripts/tool-versions-to-env.sh + - name: dotenv + uses: falti/dotenv-action@v0.2.7 + id: dotenv + - name: Setup go ${{ steps.dotenv.outputs.golang_version }} + uses: actions/setup-go@v2 with: - go-version: 1.17 + go-version: ${{ steps.dotenv.outputs.golang_version }} - name: Install Solana CLI run: ./scripts/install-solana-ci.sh - name: Build @@ -23,32 +27,3 @@ jobs: run: go test ./pkg/... -v - name: Test with the race detector enabled run: go test ./pkg/... -v -race -count=10 - - lint: - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v2 - - name: golangci-lint - uses: golangci/golangci-lint-action@v2 - with: - # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version - # version: v1.29 - - # Optional: working directory, useful for monorepos - # working-directory: somedir - - # Optional: golangci-lint command line arguments. - args: --enable=gofmt --tests=false --exclude-use-default --timeout=5m0s - - # Optional: show only new issues if it's a pull request. The default value is `false`. - # only-new-issues: true - - # Optional: if set to true then the action will use pre-installed Go. - # skip-go-installation: true - - # Optional: if set to true then the action don't cache or restore ~/go/pkg. - # skip-pkg-cache: true - - # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. - # skip-build-cache: true diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 36ec4d389..15ea6e8eb 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,13 +1,14 @@ name: rust -on: [push] +on: + push: defaults: run: working-directory: contracts jobs: - test: - name: Test + rust_run_anchor_tests: + name: Rust Run Anchor Tests runs-on: ubuntu-latest container: image: projectserum/build:v0.22.1 @@ -43,8 +44,8 @@ jobs: yarn install --frozen-lockfile anchor test - lint: - name: Lint + rust_lint: + name: Rust Lint runs-on: ubuntu-latest container: image: projectserum/build:v0.22.1 diff --git a/.gitignore b/.gitignore index 44964b95c..8d30f99e7 100644 --- a/.gitignore +++ b/.gitignore @@ -34,5 +34,6 @@ gauntlet/packages/gauntlet-solana-contracts/artifacts/bin gauntlet/packages/gauntlet-serum-multisig/networks/.env.local # test +id.json tests/e2e/logs tests/e2e/smoke/logs diff --git a/.tool-versions b/.tool-versions index a330814eb..d2c4a8945 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,5 @@ -nodejs 14.19.0 -golang 1.17.7 \ No newline at end of file +nodejs 14.19.1 +rust 1.59.0 +golang 1.17.8 +pulumi 3.25.1 +ginkgo 2.1.3 diff --git a/Makefile b/Makefile index 528da6cbf..0128e8dbf 100644 --- a/Makefile +++ b/Makefile @@ -3,14 +3,46 @@ export GOPATH ?= $(shell go env GOPATH) export GO111MODULE ?= on export PROJECT_SERUM_IMAGE ?= projectserum/build:v0.22.1 +LINUX=LINUX +OSX=OSX +WINDOWS=WIN32 +OSFLAG := +ifeq ($(OS),Windows_NT) + OSFLAG = $(WINDOWS) +else + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S),Linux) + OSFLAG = $(LINUX) + endif + ifeq ($(UNAME_S),Darwin) + OSFLAG = $(OSX) + endif +endif + download: go mod download install: - go get github.com/onsi/ginkgo/v2/ginkgo/generators@v2.1.2 - go get github.com/onsi/ginkgo/v2/ginkgo/internal@v2.1.2 - go get github.com/onsi/ginkgo/v2/ginkgo/labels@v2.1.2 - go install github.com/onsi/ginkgo/v2/ginkgo +ifeq ($(OSFLAG),$(WINDOWS)) + echo "If you are running windows and know how to install what is needed, please contribute by adding it here!" + exit 1 +endif +ifeq ($(OSFLAG),$(OSX)) + brew install asdf + asdf plugin-add nodejs https://github.com/asdf-vm/asdf-nodejs.git || true + asdf plugin-add rust https://github.com/code-lever/asdf-rust.git || true + asdf plugin-add golang https://github.com/kennyp/asdf-golang.git || true + asdf plugin-add ginkgo https://github.com/jimmidyson/asdf-ginkgo.git || true + asdf plugin-add pulumi || true + asdf install +endif +ifeq ($(OSFLAG),$(LINUX)) +ifneq ($(CI),true) + # install nix + sh <(curl -L https://nixos-nix-install-tests.cachix.org/serve/vij683ly7sl95nnhb67bdjjfabclr85m/install) --daemon --tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve --nix-extra-conf-file ./nix.conf +endif + go install github.com/onsi/ginkgo/v2/ginkgo@v$(shell ./scripts/tool-versions-to-env.sh GINKGO_VERSION) +endif anchor_shell: docker run --rm -it -v $(shell pwd):/workdir --entrypoint bash ${PROJECT_SERUM_IMAGE} @@ -24,8 +56,8 @@ build_contracts: build: build_js build_contracts test_relay_unit: - go build -v ./pkg/solana/... - go test -v ./pkg/solana/... + go build -v ./pkg/... + go test -v ./pkg/... test_smoke: SELECTED_NETWORKS=solana NETWORK_SETTINGS=$(shell pwd)/tests/e2e/networks.yaml ginkgo tests/e2e/smoke diff --git a/docs/README.md b/docs/README.md index 9182de984..193f2a527 100644 --- a/docs/README.md +++ b/docs/README.md @@ -7,3 +7,9 @@ - **[Multisig](./multisig/)**: How to setup and use the multisig program. -- **[Relay](./relay/)**: Details on the configuration options within a job spec. - **[Running E2E Tests](./RunningE2eTests.md)**: How to run the E2E Tests + +## Local initial setup + +```bash +make install +``` diff --git a/docs/gauntlet/gauntlet-setup.md b/docs/gauntlet/gauntlet-setup.md new file mode 100644 index 000000000..3a7b969c4 --- /dev/null +++ b/docs/gauntlet/gauntlet-setup.md @@ -0,0 +1,16 @@ +# Gauntlet Solana + +Install node version with asdf. Which can be done by running this from the base of the chainlink-solana repository: + +```bash +make install +``` + +You can then run yarn to setup yarn from the gauntlet directory + +```bash +cd gauntlet +yarn +``` + +From here you should be setup to run any yarn scripts in the package.json file as needed. diff --git a/gauntlet/.nvmrc b/gauntlet/.nvmrc deleted file mode 100644 index d630e949a..000000000 --- a/gauntlet/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -14.18.2 \ No newline at end of file diff --git a/gauntlet/README.md b/gauntlet/README.md index dcc4ce960..8cac4b39c 100644 --- a/gauntlet/README.md +++ b/gauntlet/README.md @@ -1,10 +1,3 @@ # Gauntlet Solana -### Set up `nvm` and install dependencies - -Install [Node Version Manager](https://github.com/nvm-sh/nvm) to help you manage multiple Node.js versions if you haven't already. Then, - -``` -nvm use -yarn -``` +For more information, see the [Chainlink Solana Documentation](./docs/gauntlet). diff --git a/nix.conf b/nix.conf new file mode 100644 index 000000000..c7d7291eb --- /dev/null +++ b/nix.conf @@ -0,0 +1 @@ +experimental-features = nix-command flakes diff --git a/scripts/tool-versions-to-env.sh b/scripts/tool-versions-to-env.sh new file mode 100755 index 000000000..0b4f34b57 --- /dev/null +++ b/scripts/tool-versions-to-env.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash + +# Script to read .tool-versions library versions into environment variables +# in the form of LIBRARY_NAME_VERSION=VERSION_NUMBER + +# get this scripts directory +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +ENV_FILE=${SCRIPT_DIR}/../.env + +# Change to the repository base. +cd ${SCRIPT_DIR}/../ + +# First argument is a boolean of 0 = false or 1 = true to echo the variable. +# Second argument is the string to echo to std out. +to_echo() { + if [ $1 -eq 1 ] + then + echo "$2" + fi +} + +# First argument is the boolean of 0 = false or 1 = true to echo what is parsed to std out. +read_tool_versions_write_to_env() { + # clear the env file before writing to it later + echo "" > ${ENV_FILE} + # loop over each line of the .tool-versions file + while read line; do + to_echo ${1} "Original line: $line" + # split the line into a bash array using the default space delimeter + lineArray=($line) + # get the key and value from the array, set the key to all uppercase + key=${lineArray[0]^^} + value=${lineArray[1]} + # ignore comments, comments always start with # + if [[ ${key:0:1} != "#" ]]; + then + to_echo ${1} "Parsed line: ${key}_VERSION=${value}" + # echo the variable to the .env file + echo "${key}_VERSION=${value}" >> ${ENV_FILE} + fi + done <.tool-versions +} + +# We have two use cases +# 1. In the make file we have commands that need just the version for a single library and +# being able to just grab that single one inline is very helpful. For this we pass in the +# library we want the version for and only its version will be sent to std out. +# 2. In CI we want to convert the tool-versions to an env file that can then be used by tools +# like dotenv to read those into github actions outputs. For this we do not pass any arguments +# to the script. +if [ $# -eq 1 ] +then + # Use case 1 + # If argument is passed only echo the version number for the specified library to std out + read_tool_versions_write_to_env 0 + # load the env file variables + source ${ENV_FILE} + # print the variable specified in stdin + echo "${!1^^}" +else + # Use case 2 + # If no argument is passed just echo all the read versions to std out, which is useful + # if something goes wrong in CI. + read_tool_versions_write_to_env 1 + echo "You can run 'source .env' to load these environment variables into your shell now." +fi diff --git a/shell.nix b/shell.nix index 90379a74b..37bf85115 100644 --- a/shell.nix +++ b/shell.nix @@ -16,6 +16,7 @@ pkgs.mkShell { anchor # Golang + # Keep this golang version in sync with the version in .tool-versions please go_1_17 gopls delve @@ -25,6 +26,7 @@ pkgs.mkShell { # NodeJS + TS nodePackages.typescript nodePackages.typescript-language-server + # Keep this nodejs version in sync with the version in .tool-versions please nodejs-14_x (yarn.override { nodejs = nodejs-14_x; }) python3