forked from opensearch-project/security-dashboards-plugin
-
Notifications
You must be signed in to change notification settings - Fork 10
98 lines (90 loc) · 3.88 KB
/
dev-environment.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# This workflow downloads the source code at the given git reference
# (branch, tag or commit), an sets up an environment (Kibana or OpenSearch)
# to run this code and a command (build, test, ...).
#
# This workflow is used as a base for other workflows.
name: Base workflow - Environment
on:
workflow_call:
inputs:
reference:
required: true
type: string
default: master
description: Source code reference (branch, tag or commit SHA).
command:
required: true
type: string
default: 'yarn build'
description: Command to run in the environment
docker_run_extra_args:
type: string
default: ''
description: Additional paramaters for the docker run command.
required: false
artifact_name:
type: string
default: ''
description: Artifact name (will be automatically suffixed with .zip)
required: false
artifact_path:
type: string
default: ''
description: Folder to include in the archive.
required: false
notify_jest_coverage_summary:
type: boolean
default: false
required: false
jobs:
# Deploy the plugin in a development environment and run a command
# using a pre-built Docker image, hosted in Quay.io.
deploy_and_run_command:
name: Deploy and run command
runs-on: ubuntu-latest
steps:
- name: Step 01 - Download the plugin's source code
uses: actions/checkout@v4
with:
repository: wazuh/wazuh-security-dashboards-plugin
ref: ${{ inputs.reference }}
path: wazuh-security-plugin
# Fix source code ownership so the internal user of the Docker
# container is also owner.
- name: Step 02 - Change code ownership
run: sudo chown 1000:1000 -R wazuh-security-plugin;
- name: Step 03 - Set up the environment and run the command
run: |
# Read the platform version from the package.json file
echo "Reading the platform version from the package.json...";
platform_version=$(jq -r '.opensearchDashboards.version | select(. != null)' wazuh-security-plugin/package.json);
echo "Plugin platform version: $platform_version";
# Up the environment and run the command
docker run -t --rm \
-e OPENSEARCH_DASHBOARDS_VERSION=${platform_version} \
-v `pwd`/wazuh-security-plugin:/home/node/kbn/plugins/wazuh-security-plugin \
${{ inputs.docker_run_extra_args }} \
quay.io/wazuh/osd-dev:${platform_version} \
bash -c '
yarn config set registry https://registry.yarnpkg.com;
cd /home/node/kbn/plugins/wazuh-security-plugin && yarn && ${{ inputs.command }};
'
- name: Get the plugin version and format reference name
run: |
echo "githubReference=$(echo ${{ inputs.reference }} | sed 's/\//-/g')" >> $GITHUB_ENV
echo "version=$(jq -r '.wazuh.version' $(pwd)/wazuh-security-plugin/package.json)" >> $GITHUB_ENV
echo "revision=$(jq -r '.wazuh.revision' $(pwd)/wazuh-security-plugin/package.json)" >> $GITHUB_ENV
- name: Step 04 - Upload artifact to GitHub
if: ${{ inputs.artifact_name && inputs.artifact_path }}
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact_name }}_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip
path: ${{ inputs.artifact_path }}
overwrite: true
- name: Step 05 - Upload coverage results to GitHub
if: ${{ inputs.notify_jest_coverage_summary && github.event_name == 'pull_request' }}
uses: AthleticNet/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
path: ./wazuh-security-plugin/target/test-coverage/coverage-summary.json
title: 'Code coverage (Jest)'