Skip to content

Commit 66339f7

Browse files
jeniiicjwooo
andauthored
[FAI-15921] Add e2e testings for Windows system in CI (#131)
Co-authored-by: Chris Wu <[email protected]>
1 parent 31615b2 commit 66339f7

File tree

15 files changed

+709
-325
lines changed

15 files changed

+709
-325
lines changed

.github/workflows/ci.yaml

Lines changed: 61 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ jobs:
6363

6464
test:
6565
name: Test NodeJS Cli
66+
needs: [build]
6667
strategy:
6768
matrix:
6869
os:
@@ -72,8 +73,7 @@ jobs:
7273
- macos-latest # macos arm64
7374
- windows-latest # windows x64
7475
runs-on: ${{ matrix.os }}
75-
timeout-minutes: 20
76-
needs: [build]
76+
timeout-minutes: 60
7777
steps:
7878
- name: Check out
7979
uses: actions/checkout@v4
@@ -110,22 +110,15 @@ jobs:
110110
# Run the binary: make sure the binary executes fine on the system/arch
111111
- name: Run binary
112112
working-directory: airbyte-local-cli-nodejs/out/pkg
113-
run: |
114-
./airbyte-local --help
113+
run: ./airbyte-local --help
115114

115+
# We use Shellspec to run the tests in Bash
116116
- name: Install ShellSpec
117-
if: matrix.os == 'ubuntu-latest'
118117
shell: bash
119-
run: |
120-
curl -fsSL https://git.io/shellspec | sh -s 0.28.1 --yes
118+
run: curl -fsSL https://git.io/shellspec | sh -s 0.28.1 --yes
121119

122-
##
123-
# Run ShellSpec tests
124-
# - linux: run on x64 but not arm64 as we don't have arm64 aibtye images
125-
# - macos: doesn't have docker by default in the github runner. Too much work to configure and Macos syntax should be relatively the same as linux
126-
# - windows: TODO
127-
##
128-
- name: Run ShellSpec tests
120+
# Run ALL e2e tests on Linux x64
121+
- name: Run Bash tests (Linux x64)
129122
if: matrix.os == 'ubuntu-latest'
130123
working-directory: airbyte-local-cli-nodejs
131124
env:
@@ -135,6 +128,60 @@ jobs:
135128
cp -rf ./test/resources ./test/exec/
136129
shellspec --chdir ./test/exec
137130
131+
# Run partial e2e tests (excluding docker tests)
132+
# - linux arm64: without pushing arm64 airbye connector images, the tests will fail
133+
- name: Run Bash tests (Linux arm64)
134+
if: matrix.os == 'ubuntu-arm64'
135+
working-directory: airbyte-local-cli-nodejs
136+
run: |
137+
cp ./out/pkg/airbyte-local ./test/exec/airbyte-local
138+
cp -rf ./test/resources ./test/exec/
139+
shellspec --chdir ./test/exec --tag argvParsing,main
140+
141+
# Run partial e2e tests (excluding any tests related to docker check)
142+
# - macos: doesn't have docker by default in the github runner. Too much work to configure and Macos syntax should be relatively the same as linux
143+
- name: Run Bash tests (MacOS)
144+
if: runner.os == 'MacOS'
145+
working-directory: airbyte-local-cli-nodejs
146+
run: |
147+
cp ./out/pkg/airbyte-local ./test/exec/airbyte-local
148+
cp -rf ./test/resources ./test/exec/
149+
export PATH="$HOME/.local/bin:$PATH"
150+
which shellspec
151+
shellspec --chdir ./test/exec --tag argvParsing
152+
153+
# Run partial e2e tests on Windows bash (excluding docker tests)
154+
# - windows: requires to config the shellspec in PATH. Separete to its own step to run
155+
- name: Run Bash tests (Windows)
156+
if: matrix.os == 'windows-latest'
157+
working-directory: airbyte-local-cli-nodejs
158+
shell: bash
159+
run: |
160+
cp ./out/pkg/airbyte-local ./test/exec/airbyte-local
161+
cp -rf ./test/resources ./test/exec/
162+
163+
# shellspec is installed in $HOME/.local/bin
164+
export PATH="$HOME/.local/bin:$PATH"
165+
which shellspec
166+
shellspec --chdir ./test/exec --tag argvParsing,main
167+
168+
# Run all e2e tests on Windows powershell
169+
# We use Pester to run e2e tests on Windows powershell. Pester is pre-installed on the Windows runner
170+
- name: Run Powershell tests (Windows)
171+
if: matrix.os == 'windows-latest'
172+
working-directory: airbyte-local-cli-nodejs
173+
shell: pwsh
174+
env:
175+
FAROS_API_KEY: ${{ secrets.FAROS_API_KEY }}
176+
run: |
177+
# cp ./out/pkg/airbyte-local ./test/airbyte-local
178+
Copy-Item -Path ./out/pkg/airbyte-local.exe -Destination ./test/airbyte-local.exe
179+
# cd ./test
180+
Set-Location -Path ./test
181+
182+
# Run Pester
183+
Invoke-Pester -Output Detailed ./pester/index.Tests.ps1
184+
138185
tag:
139186
name: Tag
140187
needs: [test]

airbyte-local-cli-nodejs/DEVELOPER.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# WIP: Airbyte CLI Rewrite
1+
# Airbyte Local CLI
2+
3+
This is the manaual for developers
24

35
```sh
46
nvm use # Use Node v22
@@ -12,7 +14,7 @@ npm run pkg # Packaging with yao-pkg and generate an executable in out/pkg
1214

1315
### Node Js Testing
1416

15-
Please make sure you have a valid DEV Faros api key set in `FARO_API_KEY` environment variable and you have your docker on, otherwise some integration tests would fail.
17+
Please make sure you have a valid DEV Faros api key set in `FAROS_API_KEY` environment variable and you have your docker running, otherwise some integration tests would fail. All tests are running against DEV so you need to create the api key in dev instead of prod.
1618

1719
```sh
1820
# Run typescript unit and integration tests
@@ -26,8 +28,13 @@ npm test
2628

2729
### CLI Executable Testing
2830

29-
For shell testing, we use shellspec. Please install shellspec in your terminal to test it locally.
30-
Same as above, you will need to set in `FARO_API_KEY` environment variable and have your docker on.
31+
It should be easy to run Bash testing locally, while we rely Github action to do Powershell testing.
32+
If you want to add new e2e testing, please make sure you add to both Bash and Powershell if possible.
33+
34+
#### Bash Testing
35+
36+
For Bash shell testing, we use shellspec. Please install shellspec in your terminal to test it locally.
37+
Same as above, you will need to set DEV `FAROS_API_KEY` environment variable and have your docker running.
3138

3239
```sh
3340
# Install shellspec on MacOS
@@ -40,4 +47,30 @@ export FARO_API_KEY="<valid_DEV_faros_api_key>"
4047
npm run shellspec
4148
```
4249

50+
Tests are tagged with 3 different tags `argvParsing`, `main`, `docker`.
51+
This is mostly for testing in different System/Arch in Github CI. We do different level of testing on different System/Arch depending on how the Github runner's capability, e.g. Github Mac runner doesn't have docker installed.
52+
53+
- `argvParsing`: testing arguments parsing.
54+
- `main`: testing the main logic in the CLI that is after checking Docker is installed.
55+
- `docker`: testing anything that will spin up a docker container.
56+
4357
Note: If you want to add new file to test, please remember to add `_spec.sh` postfix to your filename. Otherwise, shellspec won't pick your tests up.
58+
59+
#### Powershell Testing on Windows
60+
61+
We use Pester to run Powershell testing.
62+
It's now enabled on github action and the test are defined in `./tests/pester/index.Tests.ps1`.
63+
64+
Since Github Windows runner ([Windows Server 2022](https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md)) only support running Windows images, we pushed 3 testing Windows images for Airbyte connnector.
65+
They are all tagged with `windows-v0.14.11-rc0` as they are based on `v0.14.11`.
66+
67+
- `farosai/airbyte-example-source:windows-v0.14.11-rc0`
68+
- `farosai/airbyte-faros-graphql-source:windows-v0.14.11-rc0`
69+
- `farosai/airbyte-faros-destination:windows-v0.14.11-rc0`
70+
71+
Please note that we do not support running Windows images on Windows in the CLI. We only support Linux images on Windows system. These Windows images are for testing purpose only.
72+
If you want to push or update the images, you can refer to branch [`jg/windows-test-images`](https://github.com/faros-ai/airbyte-connectors/tree/jg/windows-test-images) in repo `faros-ai/airbyte-connectors`. There are Dockerfiles and steps in Github CI to build and push the test images.
73+
74+
## Packaging
75+
76+
We package the NodeJs project to executables by using [yao-pkg](https://github.com/yao-pkg/pkg). We picked it as the popular `pkg` tool from Vercel is archived and `yao-pkg` seems to be the next most maintainable option.

airbyte-local-cli-nodejs/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ Here is the steps of downloading the CLI on MacOS. Linux should have very simila
4444

4545
```sh
4646
# Download from the CLI
47-
# Please swap out `v0.0.1-beta.6` to the version you want
48-
wget -O airbyte-local.zip https://github.com/faros-ai/airbyte-local-cli/releases/download/v0.0.1-beta.6/airbyte-local-macos-arm64.zip | unzip -o airbyte-local.zip
47+
# Please swap out `v0.0.5` to the version you want
48+
wget -O airbyte-local.zip https://github.com/faros-ai/airbyte-local-cli/releases/download/v0.0.5/airbyte-local-macos-arm64.zip | unzip -o airbyte-local.zip
4949

5050
# run `--help` or `--version` to check if the CLI is installed correctly
5151
./airbyte-local # this shows the help manual
@@ -57,8 +57,8 @@ wget -O airbyte-local.zip https://github.com/faros-ai/airbyte-local-cli/releases
5757

5858
```ps1
5959
# Download from the CLI
60-
# Please swap out `v0.0.1-beta.6` to the version you want
61-
Invoke-WebRequest -Uri "https://github.com/faros-ai/airbyte-local-cli/releases/download/v0.0.1-beta.6/airbyte-local-win-x64.zip" -OutFile "airbyte-local-win-x64.zip"
60+
# Please swap out `v0.0.5` to the version you want
61+
Invoke-WebRequest -Uri "https://github.com/faros-ai/airbyte-local-cli/releases/download/v0.0.5/airbyte-local-win-x64.zip" -OutFile "airbyte-local-win-x64.zip"
6262
Expand-Archive -Path "airbyte-local-win-x64.zip" -DestinationPath . -Force
6363
6464
# run `--help` or `--version` to check if the CLI is installed correctly

airbyte-local-cli-nodejs/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

airbyte-local-cli-nodejs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@faros-ai/airbyte-local-cli-nodejs",
3-
"version": "0.0.4",
3+
"version": "0.0.5",
44
"description": "Airbyte local cli node js version",
55
"private": true,
66
"packageManager": "^[email protected]",

0 commit comments

Comments
 (0)