diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2d945ba28..78085325c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,62 +7,129 @@ on: - v*.*.* pull_request: -name: Testing - jobs: - linux-tests: - name: "Linux Tests" - strategy: - matrix: - node: [20] - runs-on: ubuntu-latest + # TODO: run tests on mac + linux-test: + name: "test on linux" + env: + CC: clang + CXX: clang++ + npm_config_clang: 1 + GYP_DEFINES: use_obsolete_asm=true + DEBIAN_FRONTEND: "noninteractive" + runs-on: ubuntu-20.04 container: ubuntu:20.04 steps: - - name: Install Dependencies for Ubuntu - run: apt-get update && apt-get install -y software-properties-common git build-essential clang libssl-dev libkrb5-dev libc++-dev wget python3 - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - DEBIAN_FRONTEND: "noninteractive" - - - name: Setup Environment + - name: prerequisites + run: | + apt-get update + apt-get install -y software-properties-common git build-essential clang libssl-dev libkrb5-dev libc++-dev wget python3 + - uses: actions/checkout@v4 + with: + submodules: true + - uses: actions/setup-node@v4 + with: + node-version: 20 + check-latest: true + - name: Test run: | + set -xe mkdir ~/.ssh_tests chmod 700 ~/.ssh_tests printf "%b" "Host *\n\tStrictHostKeyChecking no\n" > ~/.ssh_tests/config printf "%b" "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDBkHMoNRRkHYNE7EnQLdFxMgVcqGgNPYDhrWiLMlYuzpmEcUnhwW3zNaIa4J2JlGkRNgYZVia1Ic1V3koJPE3YO2+exAfJBIPeb6O1qDADc2hFFHzd28wmHKUkO61yzo2ZjDQfaEVtjN39Yiy19AbddN3bzNrgvuQT574fa6Rghl2RfecKYO77iHA1RGXIFc8heXVIUuUV/jHjb56WqoHH8vyt1DqUz89oyiHq8Cku0qzKN80COheZPseA1EvT0zlIgbXBxwijN4xRmvInK0fB5Kc9r3kddH2tT7V09bOFJsvGQaQmQ1WFTCqjpBFw1CHKcbfPLOxbLpVIR9gyx03R\n" > ~/.ssh_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m2gJKTvam3dYNaiAfq5DyhP\nzDCZNJ5rrSMprXsuRv2O4c5u8qtJ5ByaOJBjOr0CgYBMlkAxzkpUssS5CaaZDiLv\nLbfEr3HRLjYdc5KpzLBQ8NpJzhmfiIJsK1Wf8B0qb2J1XJg2Oy0KwFOgPbWIoryY\nSg19Pq98Cdn1UWCOrSabr8ZIaKe55WTgGcc8/O3k6BsNfaO9PJZfSssNUlCCtml1\n18u+uo9RJPhPDBd7Gj7r8QKBgFraxWy7t24xkZMDgK4fiM/3tQhFvhz/CY2wPbxG\n5Ae8UfkmLcOCUfTIReqfd9fAnsAFZNIKa5izHRu/wsh9NwYIJSlvm8PsEVtTrPRy\nfgvWet+i24/2eYZGsag8b19gaLCNKQzXDT1czYg8RNVsRSX427BoLzXeXNkW9uNu\nFbI9AoGAV2kxcdcKS4BtNHKPeGgV87dM0DWhQaAtEXEIcQquFtba0lAXioGHg8U4\nzeiugl4Qzchwk5qd3wnZ4SOhx0s16/5gQDlnkbjFR6EREUnvLRwV92zBXUTOGIkh\nZ7Z4rcgUKlVAaHT3OHN/lTyqJG/ib+K4wZhbztl/ox+JUFsvD98=\n-----END RSA PRIVATE KEY-----\n" > ~/.ssh_tests/id_rsa + ls ~/.ssh_tests chmod 600 ~/.ssh_tests/id_rsa* git config --global user.name "John Doe" git config --global user.email johndoe@example.com + eval "$(ssh-agent -s)" + ssh-add ~/.ssh_tests/id_rsa + + npm install + npm test + + mac-test: + name: "macOS tests" + env: + CC: clang + CXX: clang++ + npm_config_clang: 1 + GYP_DEFINES: use_obsolete_asm=true + runs-on: macos-13 + steps: - uses: actions/checkout@v4 with: submodules: true - - - name: Use Node.js - uses: actions/setup-node@v4 - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true + - uses: actions/setup-node@v4 with: - node-version: ${{ matrix.node }} + node-version: 20 check-latest: true + - name: Test + run: | + set -xe + mkdir ~/.ssh_tests + chmod 700 ~/.ssh_tests + printf "%b" "Host *\n\tStrictHostKeyChecking no\n"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h_tests + chmod 600 ~/.ssh_tests/id_rsa* + git config --global user.name "John Doe" + git config --global user.email johndoe@example.com + + eval "$(ssh-agent -s)" + ssh-add ~/.ssh_tests/id_rsa + + npm install + npm test + # TODO: limit this job to main and v... tags? + build: + needs: [linux-test] + name: build + strategy: + matrix: + node: [20] + os: + - name: darwin + architecture: x86-64 + host: macos-13 + + - name: linux + architecture: x86-64 + host: ubuntu-20.04 + env: + # TODO: verify that we need all these + CC: clang + CXX: clang++ + npm_config_clang: 1 + GYP_DEFINES: use_obsolete_asm=true + runs-on: ${{ matrix.os.host }} + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: actions/setup-node@v4 + with: + node-version: 20 + check-latest: true - name: Install - env: - CC: clang - CXX: clang++ - npm_config_clang: 1 - GYP_DEFINES: use_obsolete_asm=true run: | - npm install -g prebuildify node-gyp - npm install --ignore-scripts - npm run generate - prebuildify --napi --strip -t $(node --version | tr -d 'v') + [[ $(uname -o) == *Linux ]] && \ + sudo apt-get update && \ + sudo apt-get install -y software-properties-common git build-essential clang libssl-dev libkrb5-dev libc++-dev wget python3 npm install - - name: Test + - name: Prebuildify run: | - set -e - eval `ssh-agent -s` - ssh-add ~/.ssh_tests/id_rsa - node utils/retry npm test + npm install -g prebuildify + prebuildify --napi --strip -t "$(node --version | tr -d 'v')" + + # TODO: combine the artifacts into a package and upload the package + - uses: actions/upload-artifact@v3 + with: + name: prebuilds + path: prebuilds + retention-days: 14 diff --git a/.gitignore b/.gitignore index 99a83fc4a..6c58abbb9 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,6 @@ jsconfig.json test/id_rsa test/nodegit-test-rsa + +gibberish +prebuilds diff --git a/package.json b/package.json index 916276b0b..ff1a21c23 100644 --- a/package.json +++ b/package.json @@ -70,8 +70,7 @@ "generateJson": "node generate/scripts/generateJson", "generateMissingTests": "node generate/scripts/generateMissingTests", "generateNativeCode": "node generate/scripts/generateNativeCode", - "generate": "node lifecycleScripts/preinstall", - "install": "node-gyp-build", + "install": "node lifecycleScripts/preinstall.js && node-gyp-build", "installDebug": "BUILD_DEBUG=true npm install", "lint": "jshint lib test/tests test/utils lifecycleScripts", "mergecov": "lcov-result-merger 'test/**/*.info' 'test/coverage/merged.lcov' && ./lcov-1.10/bin/genhtml test/coverage/merged.lcov --output-directory test/coverage/report",