diff --git a/.buildkite/README.md b/.buildkite/README.md new file mode 100644 index 00000000000..6313748aaf0 --- /dev/null +++ b/.buildkite/README.md @@ -0,0 +1,50 @@ +# Buildkite Configuration + +The Cardano Wallet uses [buildkite](https://buildkite.com/cardano-foundation/cardano-wallet) as its main CI, with some actions still being run on [GitHub](https://github.com/cardano-foundation/cardano-wallet/actions). The pipeline(s) are run on self-hosted Linux/MacOS/Windows machines and we list here some requirements for those machines. + +## Windows Machine + +### System configuration + +We assume the machine is configured with a recent windows version (2022 Server?) and has winget installed. + +* Install [Windows Buildkite](https://buildkite.com/docs/agent/v3/windows) agent + * Note the "automated" Powershell install did not work so the agent was installed following the manual process +* Install the **Ruby** environment in version 2.7 using winget (the E2E tests are defined using Ruby, in a version which noone ever bothered upgrading: + ``` + winget install RubyInstallerTeam.Ruby.2.7 --force --disable-interactivity --accept-source-agreements --accept-package-agreements + ``` + This was done once through the pipeline step and then removed because we don't want to pay the 3 minutes price of forcing Ruby installation whereas it could just know it's already installed and skip it +* Install Ruby installer toolkit to be able to compile native extensions + ``` + ridk install + ``` +* Install some more packages + * `winget install zstandard` is probably needed for decompressing hosted archive (but probably not as it's natively suppported by tar) + * `winget install nssm` which is needed to run cardano-node as a service + +### Buildkite Agent configuration + +* Use powershell for scripts and have a wider definition of redacted variables + + ``` + # user powershell (because, why not?) + shell="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" + + redacted-vars="*PASSWORD*,*SECRET*,*TOKEN*,*KEY*,*_CONNECTION_STRING" + ``` +* Define `hooks\environment.bat` to store secrets needed to run the tests: + + ``` + set BUILDKITE_API_TOKEN= + set FIXTURE_DECRYPTION_KEY= + set AWS_DEFAULT_REGION= + set AWS_ACCESS_KEY_ID= + set AWS_SECRET_ACCESS_KEY= + ``` +* Define `hooks\pre-checkout.bat` to ensure node DB files can be removed (they are created readonly which breaks `git clean -xfd`) + + ``` + icacls . /grant hal:F /T /Q + ``` +* Configure buildkite agent to [run as a service](https://buildkite.com/docs/agent/v3/windows#running-as-a-service) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 899d5fe9576..000628e7975 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -12,6 +12,7 @@ env: # Per-host variables - shared across containers on host macos: "aarch64-darwin" linux: "x86_64-linux" + windows: "windows-x64" steps: @@ -34,7 +35,6 @@ steps: env: system: ${linux} - - label: Check Nix (macOS) key: macos-nix commands: @@ -296,7 +296,6 @@ steps: agents: system: ${linux} - - group: Linux Benchmarks key: linux-benchmarks depends_on: linux-nix @@ -582,9 +581,24 @@ steps: concurrency: 1 concurrency_group: 'macos-e2e-tests' + - group: Windows Agents Setup + key: windows-setup + # Assumes Ruby 2.7 + resource kit is correctly installed on the target + # machine + steps: + - label: ๐Ÿ’Ž Configure Ruby + key: windows-ruby + commands: + - cd test\e2e + - bundle install + agents: + system: ${windows} + - group: Windows Artifacts key: windows-artifacts - depends_on: linux-nix + depends_on: + - linux-nix + - windows-setup steps: - block: Build Windows Artifacts (windows) depends_on: [] @@ -613,17 +627,60 @@ steps: agents: system: ${linux} - - label: Tag as Release Candidate (windows) - if: build.env("RELEASE_CANDIDATE") != null && build.env("TEST_RC") == "FALSE" - depends_on: - - windows-package - - windows-testing-bundle - command: scripts/buildkite/main/tag-release-candidate.sh + - group: Windows Checks + depends_on: + - windows-artifacts + steps: + - label: Windows Unit Tests + command: | + cd test\e2e + bundle exec rake get_latest_windows_tests[%BUILDKITE_BRANCH%,cardano-wallet-tests-win64,any,latest] + cd cardano-wallet-tests-win64 + .\cardano-wallet-unit-test-unit.exe --color --jobs 1 --skip /Cardano.Wallet.DB.Sqlite/ +RTS -M2G -N2 agents: - system: ${linux} + system: ${windows} + env: + LOCAL_CLUSTER_CONFIGS: test\data\cluster-configs + - label: Windows Text Class Tests + command: | + cd test\e2e + bundle exec rake get_latest_windows_tests[%BUILDKITE_BRANCH%,cardano-wallet-tests-win64,any,latest] + cd cardano-wallet-tests-win64 + .\text-class-test-unit.exe --color + agents: + system: ${windows} + + - block: Windows E2E Tests + depends_on: [] + if: build.env("RELEASE_CANDIDATE") == null + key: trigger-windows-e2e-tests + + - label: โš™๏ธ Windows E2E Tests + depends_on: + - trigger-windows-e2e-tests + commands: + - cd test\e2e + - rmdir state\configs\preprod + - md state\node_db\preprod + - aws s3 cp s3://hal-team/preprod-20250102.zstd ./preprod-20250102.tar.zst + - tar xzf ./preprod-20250102.tar.zst + - mv db\* state\node_db\preprod\ + - bundle exec rake setup[preprod,%BUILDKITE_BRANCH%] + - bundle exec rake display_versions + - bundle exec rake start_node_and_wallet[preprod] + - bundle exec rake wait_until_node_synced + - bundle exec rake spec SPEC_OPTS="-t 'CardanoWallet::Shelley::StakePools'" + - bundle exec rake stop_node_and_wallet[preprod] + agents: + system: ${windows} + env: + TESTS_E2E_FIXTURES: "$FIXTURE_DECRYPTION_KEY" + concurrency: 1 + concurrency_group: 'windows-e2e-tests' - group: Docker key: docker-artifacts + if: build.env("RELEASE_CANDIDATE") != null depends_on: - linux-artifacts diff --git a/.github/workflows/e2e-windows.yml b/.github/workflows/e2e-windows.yml deleted file mode 100644 index edc342362e2..00000000000 --- a/.github/workflows/e2e-windows.yml +++ /dev/null @@ -1,158 +0,0 @@ -name: E2E Windows - -on: - push: - tags: - - rc-latest - - workflow_dispatch: - inputs: - branch: - description: 'Run tests against branch' - default: 'rc-latest' - tags: - description: 'Test tags (all, light, offchain...)' - default: 'all' -jobs: - test: - concurrency: - group: windows-e2e-group - cancel-in-progress: false - - runs-on: windows-latest - - env: - NETWORK: preprod - BUILDKITE_API_TOKEN: ${{ secrets.BUILDKITE_TOKEN_READ_BUILDS_ARTIFACTS }} - TESTS_E2E_FIXTURES: ${{ secrets.TESTS_E2E_FIXTURES }} - BRANCH: ${{ github.event.inputs.branch || 'rc-latest' }} - TAGS: ${{ github.event.inputs.tags || 'all' }} - - steps: - - name: Check space - run: Get-PSDrive - - - name: configure Pagefile - uses: al-cheb/configure-pagefile-action@v1.2 - with: - minimum-size: 16GB - maximum-size: 24GB - disk-root: "C:" - - - name: Checkout - shell: bash - run: | - git clone -b $BRANCH https://github.com/cardano-foundation/cardano-wallet.git C:/cardano-wallet --depth 1 --no-single-branch - cd /c/cardano-wallet - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.7.1 - bundler-cache: true - working-directory: C:/cardano-wallet/test/e2e - - - name: Install dependencies - working-directory: C:/cardano-wallet/test/e2e - run: bundle install - - - name: Prepare Windows - run: | - choco install wget - choco install unzip - choco install nssm - choco install archiver - - - name: ๐Ÿ•’ Get Date/Time - working-directory: C:/cardano-wallet/test/e2e - run: bundle exec rake datetime - - - name: ๐Ÿ’พ GH Cache node db - id: cache-node - uses: actions/cache@v3 - with: - path: C:/cardano-wallet/test/e2e/state/node_db/preprod - key: node-db-e2e-windows-preprod - - - name: Fetch preprod snapshot - if: steps.cache-node.outputs.cache-hit != 'true' - working-directory: C:/cardano-wallet/test/e2e - run: | - mkdir state -ErrorAction SilentlyContinue - cd state - mkdir node_db - cd node_db - mkdir preprod - cd preprod - curl -s https://downloads.csnapshots.io/testnet/testnet-db-snapshot.json | jq -r .[].file_name > snapshot.json - curl -o snapshot.tar.lz4 https://downloads.csnapshots.io/testnet/$(cat snapshot.json) - arc unarchive snapshot.tar.lz4 - mv db/* . - - - name: โš™๏ธ Setup (get latest bins and configs and decode fixtures) - working-directory: C:/cardano-wallet/test/e2e - run: bundle exec rake setup[preprod,%BRANCH%] - - - name: ๐Ÿ” Display versions - working-directory: C:/cardano-wallet/test/e2e - run: bundle exec rake display_versions - - - name: ๐Ÿš€ Start node and wallet - working-directory: C:/cardano-wallet/test/e2e - run: bundle exec rake start_node_and_wallet[preprod] - - - name: โณ Wait until node is synced - working-directory: C:/cardano-wallet/test/e2e - run: bundle exec rake wait_until_node_synced - - - name: ๐Ÿงช Run all tests - working-directory: C:/cardano-wallet/test/e2e - run: bundle exec rake spec SPEC_OPTS="-t %TAGS%" - - - name: ๐Ÿ Stop node and wallet - working-directory: C:/cardano-wallet/test/e2e - run: bundle exec rake stop_node_and_wallet[preprod] - - - name: ๐Ÿ’พ GH Save Cache of node db - if: always() - uses: actions/cache/save@v3 - with: - path: C:/cardano-wallet/test/e2e/state/node_db/preprod - key: node-db-e2e-windows-preprod - - - name: ๐Ÿ“Ž Upload state - uses: actions/upload-artifact@v3 - if: always() - with: - name: windows-state - path: | - C:/cardano-wallet/test/e2e/state/logs - C:/cardano-wallet/test/e2e/state/configs - C:/cardano-wallet/test/e2e/state/wallet_db - - report: - needs: [test] - if: always() - runs-on: ubuntu-latest - steps: - - name: Slack Notification on failure - if: needs.test.result != 'success' - uses: rtCamp/action-slack-notify@v2 - env: - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_ICON_EMOJI: ':poop:' - SLACK_USERNAME: 'GitHub Action' - SLACK_MESSAGE: | - *Job Link:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - SLACK_COLOR: '#FF0000' - - - name: Slack Notification on success - if: needs.test.result == 'success' - uses: rtCamp/action-slack-notify@v2 - env: - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_ICON_EMOJI: ':rocket:' - SLACK_USERNAME: 'GitHub Action' - SLACK_MESSAGE: | - *Job Link:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - SLACK_COLOR: '#00FF00' \ No newline at end of file diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml deleted file mode 100644 index 8809638a35f..00000000000 --- a/.github/workflows/windows.yml +++ /dev/null @@ -1,141 +0,0 @@ -name: Windows Unit Tests - -on: - push: - tags: - - rc-latest - - workflow_dispatch: - inputs: - branch: - description: 'Run tests against branch' - default: 'rc-latest' - status: - description: 'Run tests against status (use `any` as wildcard)' - default: 'passed' - required: true - type: choice - options: - - passed - - any - build: - description: 'Run tests against build number' - required: false - default: 'latest' - -jobs: - setup: - env: - BUILDKITE_API_TOKEN: ${{ secrets.BUILDKITE_TOKEN_READ_BUILDS_ARTIFACTS }} - WORK_DIR: ./test/e2e - BRANCH: ${{ github.event.inputs.branch || 'rc-latest' }} - runs-on: windows-2022 - name: Download testing bundle - steps: - - uses: actions/checkout@v3.2.0 - with: - ref: ${{ env.BRANCH }} - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.7.1 - bundler-cache: true - - - name: Get 'cardano-wallet-tests-win64.zip' - working-directory: ${{ env.WORK_DIR }} - run: | - bundle install - echo "STATUS = ${{ github.event.inputs.status }}" - echo "BUILD = ${{ github.event.inputs.build }}" - rake get_latest_windows_tests[%BRANCH%,cardano-wallet-tests-win64,${{ github.event.inputs.status || 'any' }},${{ github.event.inputs.build || 'latest' }}] - - - name: Report version - working-directory: ${{ env.WORK_DIR }} - run: rake display_versions[cardano-wallet-tests-win64] - - - name: Save files - uses: actions/upload-artifact@v4 - with: - name: cardano-wallet-tests-win64 - path: ${{ env.WORK_DIR }}/cardano-wallet-tests-win64 - - cardano-wallet-test-unit: - name: 'cardano-wallet:unit' - needs: setup - runs-on: windows-2022 - steps: - - uses: actions/download-artifact@v4 - with: - name: cardano-wallet-tests-win64 - - run: '.\\cardano-wallet-unit-test-unit.exe --color --jobs 1 --skip /Cardano.Wallet.DB.Sqlite/ +RTS -M2G -N2' - env: - LOCAL_CLUSTER_CONFIGS: test\data\cluster-configs - - text-class-test-unit: - name: 'test-class:unit' - needs: setup - runs-on: windows-2022 - steps: - - uses: actions/download-artifact@v4 - with: - name: cardano-wallet-tests-win64 - - run: '.\\text-class-test-unit.exe --color' - - cardano-wallet-launcher-test-unit: - name: 'cardano-wallet-launcher:unit' - needs: setup - runs-on: windows-2022 - steps: - - uses: actions/download-artifact@v4 - with: - name: cardano-wallet-tests-win64 - - run: '.\\cardano-wallet-launcher-test-unit.exe --color' - continue-on-error: true - - report: - needs: [cardano-wallet-test-unit, text-class-test-unit, cardano-wallet-launcher-test-unit] - if: always() - runs-on: ubuntu-latest - - steps: - - name: Slack Notification on failure - if: | - needs.cardano-wallet-launcher-test-unit.result != 'success' || - needs.cardano-wallet-test-unit.result != 'success' || - needs.text-class-test-unit.result != 'success' - - uses: rtCamp/action-slack-notify@v2 - env: - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_ICON_EMOJI: ':poop:' - SLACK_USERNAME: 'GitHub Action' - SLACK_MESSAGE: | - *Job Link:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - SLACK_COLOR: '#FF0000' - - - name: Slack Notification on success - if: | - needs.cardano-wallet-launcher-test-unit.result == 'success' && - needs.cardano-wallet-test-unit.result == 'success' && - needs.text-class-test-unit.result == 'success' - uses: rtCamp/action-slack-notify@v2 - env: - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_ICON_EMOJI: ':rocket:' - SLACK_USERNAME: 'GitHub Action' - SLACK_MESSAGE: | - *Job Link:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - SLACK_COLOR: '#00FF00' - - # ADP-2517 - Fix integration tests on Windows - # cardano-wallet-test-integration: - # name: 'cardano-wallet:integration' - # needs: setup - # runs-on: windows-2022 - # steps: - # - uses: actions/download-artifact@v4.1.7 - # with: - # name: cardano-wallet-tests-win64 - # - run: '.\\cardano-wallet-test-integration.exe --color' - # timeout-minutes: 60 diff --git a/lib/unit/test/unit/Cardano/Wallet/Application/TlsSpec.hs b/lib/unit/test/unit/Cardano/Wallet/Application/TlsSpec.hs index 02fc3515a9a..ee8b4a40df7 100644 --- a/lib/unit/test/unit/Cardano/Wallet/Application/TlsSpec.hs +++ b/lib/unit/test/unit/Cardano/Wallet/Application/TlsSpec.hs @@ -75,14 +75,11 @@ import Network.HTTP.Types.Status ( Status (..) ) import Network.TLS - ( AlertDescription (..) - , ClientHooks (..) + ( ClientHooks (..) , ClientParams (..) , Credentials (..) , Shared (..) , Supported (..) - , TLSError (..) - , TLSException (..) , noSessionManager ) import Network.TLS.Extra.Cipher @@ -121,9 +118,6 @@ import UnliftIO.Async ( async , link ) -import UnliftIO.Exception - ( fromException - ) import qualified Cardano.Wallet.Application.Server as Server import qualified Data.ByteString as BS @@ -156,11 +150,7 @@ spec = describe "TLS Client Authentication" $ do (Server.start warpSettings nullTracer (Just tlsSv) socket app) pingHttps tlsCl port `shouldThrow` \case - HttpExceptionRequest _ (InternalException e) -> - case fromException e of - Just (Terminated _ _ (Error_Protocol (_,_,alert))) -> - alert == CertificateUnknown - _ -> False + HttpExceptionRequest _ (InternalException _) -> True _ -> False it "Properly deny HTTP connection if TLS is enabled" $ do diff --git a/test/e2e/Rakefile b/test/e2e/Rakefile index 89a7b2360aa..84b5cd03988 100644 --- a/test/e2e/Rakefile +++ b/test/e2e/Rakefile @@ -321,7 +321,7 @@ end task :get_latest_configs, [:env] do |_task, args| env = args[:env] out = File.join(CONFIGS, env) - + log ">> Getting latest configs in #{out} for '#{env}'" if File.exist?(out) # The config directory is probably a /nix/store path log ">> Using config directory '#{out}'" @@ -391,6 +391,7 @@ task :setup, [:env, :branch, :skip_bins, :skip_configs] do |_task, args| if args[:skip_configs] log '>> Skipping getting latest configs.' else + log '>> Getting latest configs...' Rake::Task[:get_latest_configs].invoke(env) end