From eaf513e92c4a6f1292823418869d46e221968441 Mon Sep 17 00:00:00 2001 From: Matthew Black Date: Fri, 18 Oct 2024 15:41:08 -0400 Subject: [PATCH] ci: switch from circleci to gh actions --- .circleci/config.yml | 137 -------------------------- .github/workflows/ci.yml | 205 +++++++++++++++++++++++++++++++++++++++ package-lock.json | 8 +- package.json | 3 +- tslint.json | 4 +- yarn.lock | 8 +- 6 files changed, 219 insertions(+), 146 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/ci.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 407f309..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,137 +0,0 @@ -version: 2.1 - -executors: - default-runner: - docker: - - image: ghcr.io/cryptogarageinc/elements-testing:v0.1.0 - macos-builder: - macos: - xcode: 11.3.0 - -tag_only: &tag_only - filters: - tags: - only: /.*/ - branches: - ignore: /.*/ -workflows: - lint-build-test-integration: - jobs: - - lint - - build - - test: - requires: - - build - - integration: - requires: - - build - prebuild-release: - jobs: - - prebuild: - name: prebuild-linux - runner: default-runner - <<: *tag_only - - release: - <<: *tag_only - requires: - - prebuild-linux - -jobs: - lint: - docker: - - image: ghcr.io/cryptogarageinc/elements-testing:v0.1.0 - steps: - - checkout - - run: npm ci - - run: npm run tslint_check - - build: - docker: - - image: ghcr.io/cryptogarageinc/elements-testing:v0.1.0 - steps: - - checkout - - run: npm ci - - run: npm run cmake_all - - persist_to_workspace: - root: . - paths: - - . - test: - docker: - - image: ghcr.io/cryptogarageinc/elements-testing:v0.1.0 - steps: - - attach_workspace: - at: . - - run: npm run test_report - - store_test_results: - path: ./reports/jest - - store_artifacts: - path: ./reports/jest - - integration: - docker: - - image: ghcr.io/cryptogarageinc/elements-testing:v0.1.0 - steps: - - attach_workspace: - at: . - - run: ./integration_tests/__tests__/start-bitcoind.sh $(pwd) 'integration_tests' - - run: sleep 3 - - run: npm run test_integration - - store_artifacts: - path: ./build_coverage/lcov_cfddlc_output - destination: raw-test-output - - store_test_results: - path: ./reports/integration - - store_artifacts: - path: ./reports/integration - - prebuild: - parameters: - runner: - type: executor - setup: - description: "Steps that will run before prebuild the app" - type: steps - default: [] - pre-prebuild-cmd: - description: "command that will be run before and in the same shell as prebuild command" - type: string - default: "" - executor: << parameters.runner >> - steps: - - checkout - - steps: << parameters.setup >> - - run: - name: Setup no postinstall - command: touch .no-postinstall - - run: - name: Install modules - command: npm ci - - run: - name: Build prebuilt binaries - command: | - << parameters.pre-prebuild-cmd >> - npm run-script prebuild_all - - store_artifacts: - path: ./prebuilds - - persist_to_workspace: - root: prebuilds - paths: - - . - - release: - docker: - - image: cimg/node:lts - steps: - - checkout - - attach_workspace: - at: ./prebuilds - - run: - name: Setup no postinstall - command: touch .no-postinstall - - run: - name: Install modules - command: npm ci - - run: - name: Upload prebuilt releases - command: npm run-script prebuild_upload_all -- ${GITHUB_ACCESS_TOKEN} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8a1c60b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,205 @@ +name: CI + +on: + push: + branches: + - '**' + pull_request: + branches: + - '**' + workflow_dispatch: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Node.js + uses: actions/setup-node@v2 + with: + node-version: 'lts/*' + - run: npm ci + - run: npm run tslint_check + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Node.js + uses: actions/setup-node@v2 + with: + node-version: 'lts/*' + - run: npm ci + - run: npm run cmake_all + - name: Persist workspace + uses: actions/upload-artifact@v3 + with: + name: workspace + path: . + + test: + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v2 + - name: Download workspace + uses: actions/download-artifact@v3 + with: + name: workspace + - name: Install Docker + run: | + sudo apt-get remove -y docker docker-engine docker.io containerd runc + sudo apt-get update + sudo apt-get install -y \ + ca-certificates \ + curl \ + gnupg \ + lsb-release + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + sudo apt-get update + sudo apt-get install -y docker-ce docker-ce-cli containerd.io + - name: Run tests in Docker + run: | + docker pull ghcr.io/cryptogarageinc/elements-testing:v0.1.0 + docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace ghcr.io/cryptogarageinc/elements-testing:v0.1.0 /bin/bash -c " + npm ci && + npm run test_report + " + - name: Store test results + uses: actions/upload-artifact@v3 + with: + name: jest-reports + path: ./reports/jest + + integration: + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v2 + - name: Download workspace + uses: actions/download-artifact@v3 + with: + name: workspace + - name: Install Docker + run: | + sudo apt-get remove -y docker docker-engine docker.io containerd runc + sudo apt-get update + sudo apt-get install -y \ + ca-certificates \ + curl \ + gnupg \ + lsb-release + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + sudo apt-get update + sudo apt-get install -y docker-ce docker-ce-cli containerd.io + - name: Run integration tests in Docker + run: | + docker pull ghcr.io/cryptogarageinc/elements-testing:v0.1.0 + docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace ghcr.io/cryptogarageinc/elements-testing:v0.1.0 /bin/bash -c " + npm ci && + ./integration_tests/__tests__/start-bitcoind.sh $(pwd) 'integration_tests' && + sleep 3 && + npm run test_integration + " + - name: Store integration artifacts + uses: actions/upload-artifact@v3 + with: + name: integration-artifacts + path: ./build_coverage/lcov_cfddlc_output + - name: Store integration test results + uses: actions/upload-artifact@v3 + with: + name: integration-reports + path: ./reports/integration + + prebuild-linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Node.js + uses: actions/setup-node@v2 + with: + node-version: 'lts/*' + - run: touch .no-postinstall + - run: npm ci + - run: npm run-script prebuild_all + - name: Store Linux prebuild artifacts + uses: actions/upload-artifact@v3 + with: + name: prebuilds-linux + path: ./prebuilds + + prebuild-windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: '20.x' + + - name: Install Git + shell: powershell + run: | + choco install git --params "/GitAndUnixToolsOnPath" + + - name: Install CMake + shell: powershell + run: | + choco install cmake --installargs '"ADD_CMAKE_TO_PATH=System"' + + - name: Verify CMake, Git, and Bash installation + shell: powershell + run: | + cmake --version + git --version + bash --version + + - name: Set npm script-shell to bash + shell: powershell + run: | + npm config set script-shell "bash.exe" + + - name: Run npm ci + shell: bash + run: | + npm ci + + - name: Run prebuild script + shell: bash + run: | + npm run-script prebuild_all + + - name: Store Windows prebuild artifacts + uses: actions/upload-artifact@v3 + with: + name: prebuilds-windows + path: ./prebuilds + + release: + runs-on: ubuntu-latest + needs: [prebuild-linux, prebuild-windows] + steps: + - uses: actions/checkout@v2 + - name: Download Linux prebuild artifacts + uses: actions/download-artifact@v3 + with: + name: prebuilds-linux + - name: Download Windows prebuild artifacts + uses: actions/download-artifact@v3 + with: + name: prebuilds-windows + - name: Install Node.js + uses: actions/setup-node@v2 + with: + node-version: 'lts/*' + - run: touch .no-postinstall + - run: npm ci + - run: npm run-script prebuild_upload_all -- ${{ secrets.GH_ACCESS_TOKEN }} diff --git a/package-lock.json b/package-lock.json index 769f885..ca8911d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "big-integer": "^1.6.26", "cmake-js": "^6.1.0", "nan": "^2.14.2", + "node-abi": "^3.71.0", "node-addon-api": "^1.6.3", "node-gyp": "^5.0.2", "npm-run-all": "^4.1.5", @@ -12029,9 +12030,10 @@ "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==" }, "node_modules/node-abi": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.5.0.tgz", - "integrity": "sha512-LtHvNIBgOy5mO8mPEUtkCW/YCRWYEKshIvqhe1GHHyXEHEB5mgICyYnAcl4qan3uFeRROErKGzatFHPf6kDxWw==", + "version": "3.71.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.71.0.tgz", + "integrity": "sha512-SZ40vRiy/+wRTf21hxkkEjPJZpARzUMVcJoQse2EF8qkUWbbO2z7vd5oA/H6bVH6SZQ5STGcu0KRDS7biNRfxw==", + "license": "MIT", "dependencies": { "semver": "^7.3.5" }, diff --git a/package.json b/package.json index b32edc5..3742e9f 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "install:prod": "prebuild-install --force --verbose && mkdir -p wrap_js/build && cp -r build/* wrap_js/build/ || run-s install_cmake", "install_cmake": "run-s cmake_clean cmake_install_configure cmake_compile", "prebuild_all": "run-s prebuild_nodejs prebuild_electron", - "prebuild_nodejs": "prebuild --backend cmake-js -t 18.18.2 -t 15.1.0 -t -t 14.18.1 -t 12.18.1 -r node --verbose --include-regex \".*(node|a|so|dll|dylib)$\" -- -O build --CDENABLE_SHARED=off --CDENABLE_CAPI=off --CDENABLE_TESTS=off --CDENABLE_JSONAPI=off --CDENABLE_JS_WRAPPER=off --CDTARGET_RPATH=\"@executable_path;/usr/local/lib;/usr/local/lib64;./node_modules/cfd-dlc-js/wrap_js/build/Release;../node_modules/cfd-dlc-js/wrap_js/build/Release;../../node_modules/cfd-dlc-js/wrap_js/build/Release;../../../node_modules/cfd-dlc-js/wrap_js/build/Release;../../../../node_modules/cfd-dlc-js/wrap_js/build/Release;../../../../../node_modules/cfd-dlc-js/wrap_js/build/Release;../../../../../../node_modules/cfd-dlc-js/wrap_js/build/Release;./build/Release;./wrap_js/build/Release;./wrap_js/dl_lib/lib\" -C --CDnapi_build_version=3", + "prebuild_nodejs": "prebuild --backend cmake-js -t 20.18.0 -t 18.18.2 -t 15.1.0 -t 14.18.1 -t 12.18.1 -r node --verbose --include-regex \".*(node|a|so|dll|dylib)$\" -- -O build --CDENABLE_SHARED=off --CDENABLE_CAPI=off --CDENABLE_TESTS=off --CDENABLE_JSONAPI=off --CDENABLE_JS_WRAPPER=off --CDTARGET_RPATH=\"@executable_path;/usr/local/lib;/usr/local/lib64;./node_modules/cfd-dlc-js/wrap_js/build/Release;../node_modules/cfd-dlc-js/wrap_js/build/Release;../../node_modules/cfd-dlc-js/wrap_js/build/Release;../../../node_modules/cfd-dlc-js/wrap_js/build/Release;../../../../node_modules/cfd-dlc-js/wrap_js/build/Release;../../../../../node_modules/cfd-dlc-js/wrap_js/build/Release;../../../../../../node_modules/cfd-dlc-js/wrap_js/build/Release;./build/Release;./wrap_js/build/Release;./wrap_js/dl_lib/lib\" -C --CDnapi_build_version=3", "prebuild_electron": "prebuild --backend cmake-js -t 7.0.0 -t 7.3.0 -t 8.0.0 -t 9.0.0 -r electron --verbose --include-regex \".*(node|a|so|dll|dylib)$\" -- -O build --CDENABLE_SHARED=off --CDENABLE_CAPI=off --CDENABLE_TESTS=off --CDENABLE_JSONAPI=off --CDENABLE_JS_WRAPPER=off --CDTARGET_RPATH=\"@executable_path;/usr/local/lib;/usr/local/lib64;\\$\\$ORIGIN/node_modules/cfd-dlc-js/wrap_js/build/Release;\\$ORIGIN/node_modules/cfd-dlc-js/wrap_js/build/Release;\\$ORIGIN/../node_modules/cfd-dlc-js/wrap_js/build/Release;\\$ORIGIN/../../node_modules/cfd-dlc-js/wrap_js/build/Release;\\$ORIGIN/../../../node_modules/cfd-dlc-js/wrap_js/build/Release;\\$ORIGIN/../../../../node_modules/cfd-dlc-js/wrap_js/build/Release;\\$ORIGIN/../../../../../node_modules/cfd-dlc-js/wrap_js/build/Release;\\$ORIGIN/../../../../../../node_modules/cfd-dlc-js/wrap_js/build/Release;\\$ORIGIN/build/Release;\\$ORIGIN/wrap_js/build/Release;\\$ORIGIN/wrap_js/dl_lib/lib\" -C --CDnapi_build_version=3", "prebuild_upload_all": "prebuild --upload-all", "cmake_compile": "cmake-js compile -O wrap_js/build", @@ -97,6 +97,7 @@ "big-integer": "^1.6.26", "cmake-js": "^6.1.0", "nan": "^2.14.2", + "node-abi": "^3.71.0", "node-addon-api": "^1.6.3", "node-gyp": "^5.0.2", "npm-run-all": "^4.1.5", diff --git a/tslint.json b/tslint.json index 0070c20..cdc1f1d 100644 --- a/tslint.json +++ b/tslint.json @@ -13,7 +13,9 @@ "no-console": { "severity": "warning", "options": ["debug", "info", "log", "time", "timeEnd", "trace"] - } + }, + "no-unused-expression": false, + "label-position": false }, "jsRules": { "max-line-length": { diff --git a/yarn.lock b/yarn.lock index 5ae9cda..6d2dba0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4470,10 +4470,10 @@ node-abi@^2.21.0: dependencies: semver "^5.4.1" -node-abi@^3.0.0, node-abi@^3.3.0: - version "3.5.0" - resolved "https://registry.npmjs.org/node-abi/-/node-abi-3.5.0.tgz" - integrity sha512-LtHvNIBgOy5mO8mPEUtkCW/YCRWYEKshIvqhe1GHHyXEHEB5mgICyYnAcl4qan3uFeRROErKGzatFHPf6kDxWw== +node-abi@^3.0.0, node-abi@^3.3.0, node-abi@^3.71.0: + version "3.71.0" + resolved "https://registry.npmjs.org/node-abi/-/node-abi-3.71.0.tgz" + integrity sha512-SZ40vRiy/+wRTf21hxkkEjPJZpARzUMVcJoQse2EF8qkUWbbO2z7vd5oA/H6bVH6SZQ5STGcu0KRDS7biNRfxw== dependencies: semver "^7.3.5"