Skip to content

Commit 8d110a9

Browse files
committed
Add UT CI
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
1 parent 3db7c5c commit 8d110a9

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed
+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Run unit tests
2+
on:
3+
push:
4+
branches:
5+
- "*"
6+
pull_request:
7+
branches:
8+
- "*"
9+
env:
10+
OPENSEARCH_DASHBOARDS_VERSION: 'main'
11+
12+
jobs:
13+
Get-CI-Image-Tag:
14+
uses: opensearch-project/opensearch-build/.github/workflows/get-ci-image-tag.yml@main
15+
with:
16+
product: opensearch-dashboards
17+
18+
build-and-test-linux:
19+
needs: Get-CI-Image-Tag
20+
name: Build the plugin and run unit tests
21+
runs-on: ubuntu-latest
22+
container:
23+
image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }}
24+
options: --user root
25+
26+
steps:
27+
- name: Checkout OpenSearch Dashboards
28+
uses: actions/checkout@v2
29+
with:
30+
repository: opensearch-project/OpenSearch-Dashboards
31+
ref: ${{ env.OPENSEARCH_DASHBOARDS_VERSION }}
32+
path: OpenSearch-Dashboards
33+
- name: Checkout plugin
34+
uses: actions/checkout@v2
35+
with:
36+
path: OpenSearch-Dashboards/plugins/dashboards-flow-framework
37+
- name: Bootstrap / build / unit test the plugin
38+
run: |
39+
chown -R 1000:1000 `pwd`
40+
cd ./OpenSearch-Dashboards/
41+
su `id -un 1000` -c "source $NVM_DIR/nvm.sh && nvm use && node -v && yarn -v &&
42+
cd ./plugins/dashboards-flow-framework &&
43+
whoami && yarn osd bootstrap && yarn build && yarn run test:jest --coverage"
44+
- name: Uploads coverage
45+
uses: codecov/codecov-action@v1
46+
47+
# TODO: once github actions supports windows and macos docker containers, we can
48+
# merge these in to the above step's matrix.
49+
build-and-test-windows-macos:
50+
name: Build the plugin and run unit tests
51+
strategy:
52+
matrix:
53+
os: [macos-latest, windows-latest]
54+
runs-on: ${{ matrix.os }}
55+
steps:
56+
# Enable longer filenames for windows
57+
- name: Enable longer filenames
58+
if: ${{ matrix.os == 'windows-latest' }}
59+
run: git config --system core.longpaths true
60+
- name: Checkout OpenSearch Dashboards
61+
uses: actions/checkout@v2
62+
with:
63+
repository: opensearch-project/OpenSearch-Dashboards
64+
ref: ${{ env.OPENSEARCH_DASHBOARDS_VERSION }}
65+
path: OpenSearch-Dashboards
66+
- name: Setup Node
67+
uses: actions/setup-node@v3
68+
with:
69+
node-version-file: './OpenSearch-Dashboards/.nvmrc'
70+
registry-url: 'https://registry.npmjs.org'
71+
- name: Install Yarn
72+
# Need to use bash to avoid having a windows/linux specific step
73+
shell: bash
74+
run: |
75+
YARN_VERSION=$(node -p "require('./OpenSearch-Dashboards/package.json').engines.yarn")
76+
echo "Installing yarn@$YARN_VERSION"
77+
npm i -g yarn@$YARN_VERSION
78+
- run: node -v
79+
- run: yarn -v
80+
- name: Checkout plugin
81+
uses: actions/checkout@v2
82+
with:
83+
path: OpenSearch-Dashboards/plugins/dashboards-flow-framework
84+
- name: Bootstrap the plugin
85+
run: |
86+
cd OpenSearch-Dashboards/plugins/dashboards-flow-framework
87+
yarn osd bootstrap
88+
- name: Build the plugin
89+
run: |
90+
cd OpenSearch-Dashboards/plugins/dashboards-flow-framework
91+
yarn build
92+
- name: Run unit tests
93+
run: |
94+
cd OpenSearch-Dashboards/plugins/dashboards-flow-framework
95+
yarn run test:jest --coverage
96+
- name: Uploads coverage
97+
uses: codecov/codecov-action@v1
98+

0 commit comments

Comments
 (0)