Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Windows E2E tests on buildkite #4897

Closed
wants to merge 13 commits into from
50 changes: 50 additions & 0 deletions .buildkite/README.md
Original file line number Diff line number Diff line change
@@ -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 isntalled and skip it
abailly marked this conversation as resolved.
Show resolved Hide resolved
* 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=<needed to retrieve artifacts stored by buildkite steps>
set FIXTURE_DECRYPTION_KEY=<needed to decrypt gpg store containing wallet keys for E2E tests>
set AWS_DEFAULT_REGION=<needed to retrieve snapshot>
set AWS_ACCESS_KEY_ID=<needed to retrieve snapshot>
set AWS_SECRET_ACCESS_KEY=<needed to retrieve snapshot>
```
* 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)
40 changes: 37 additions & 3 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ env:
# Per-host variables - shared across containers on host
macos: "aarch64-darwin"
linux: "x86_64-linux"
windows: "windows-x64"

steps:

Expand All @@ -34,7 +35,6 @@ steps:
env:
system: ${linux}


- label: Check Nix (macOS)
key: macos-nix
commands:
Expand Down Expand Up @@ -296,7 +296,6 @@ steps:
agents:
system: ${linux}


- group: Linux Benchmarks
key: linux-benchmarks
depends_on: linux-nix
Expand Down Expand Up @@ -582,7 +581,7 @@ steps:
concurrency: 1
concurrency_group: 'macos-e2e-tests'

- group: Windows Artifacts
- group: Windows Build & Checks
key: windows-artifacts
depends_on: linux-nix
steps:
Expand Down Expand Up @@ -613,6 +612,41 @@ steps:
agents:
system: ${linux}

# Assumes Ruby 2.7 + resource kit is correctly installed on the target
# machine
- label: 💎 Configure Ruby
commands:
- '\$env:path'
- cd test\e2e
- bundle install
agents:
system: ${windows}

- label: ⚙️ Download snapshot, decode fixtures, & run some E2E tests
key: windows-setup
depends_on:
- windows-package
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
- arc unarchive ./preprod-20250102.tar.zst
- mv preprod-20250102\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'


- label: Tag as Release Candidate (windows)
if: build.env("RELEASE_CANDIDATE") != null && build.env("TEST_RC") == "FALSE"
depends_on:
Expand Down
50 changes: 19 additions & 31 deletions .github/workflows/e2e-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,36 +58,31 @@ jobs:

- name: Prepare Windows
run: |
choco install wget
choco install unzip
choco install nssm
choco install archiver
choco install zstandard
choco install awscli

- 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
working-directory: C:/cardano-wallet/test/e2e/
run: |
aws s3 cp --no-progress s3://${{ secrets.AWS_S3_BUCKET }}/preprod-20250102.zstd .\preprod-20250102.tar.zst
env:
AWS_DEFAULT_REGION: eu-west-1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Fetch preprod snapshot
if: steps.cache-node.outputs.cache-hit != 'true'
- name: 🎁 Unpack preprod snapshot
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/* .
mkdir state\node_db
mkdir state\node_db\preprod
cd state\node_db\preprod
tar --zstd -xf ..\..\..\preprod-20250102.tar.zst
mv db\* .

- name: ⚙️ Setup (get latest bins and configs and decode fixtures)
working-directory: C:/cardano-wallet/test/e2e
Expand All @@ -105,21 +100,14 @@ jobs:
working-directory: C:/cardano-wallet/test/e2e
run: bundle exec rake wait_until_node_synced

- name: 🧪 Run all tests
- name: 🧪 Run Some Tests
working-directory: C:/cardano-wallet/test/e2e
run: bundle exec rake spec SPEC_OPTS="-t %TAGS%"
run: bundle exec rake spec SPEC_OPTS="-e 'CardanoWallet::Shelley::Transactions'"

- 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()
Expand Down Expand Up @@ -155,4 +143,4 @@ jobs:
SLACK_USERNAME: 'GitHub Action'
SLACK_MESSAGE: |
*Job Link:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
SLACK_COLOR: '#00FF00'
SLACK_COLOR: '#00FF00'
3 changes: 2 additions & 1 deletion test/e2e/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}'"
Expand Down Expand Up @@ -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

Expand Down
Loading