-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
133 lines (122 loc) · 6.28 KB
/
action.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: 'Configure Datadog Test Visibility'
description: 'Installs Datadog tracers for configured languages and enables Test Visibility'
branding:
icon: 'bar-chart'
color: 'purple'
inputs:
languages:
description: 'List of languages to be instrumented. Can be either "all" or any of "java", "js", "python", "dotnet" (multiple languages can be specified as a space-separated list).'
required: true
service:
description: 'The name of the service or library being tested.'
required: false
api_key:
description: 'Datadog API key. Can be found at https://app.datadoghq.com/organization-settings/api-keys'
required: false
site:
description: 'Datadog site (optional). See https://docs.datadoghq.com/getting_started/site for more information about sites.'
required: false
default: datadoghq.com
dotnet-tracer-version:
description: 'The version of Datadog .NET tracer to use (optional). Defaults to the latest release.'
required: false
java-tracer-version:
description: 'The version of Datadog Java tracer to use (optional). Defaults to the latest release.'
required: false
js-tracer-version:
description: 'The version of Datadog JS tracer to use (optional). Defaults to the latest release.'
required: false
python-tracer-version:
description: 'The version of Datadog Python tracer to use (optional). Defaults to the latest release.'
required: false
java-instrumented-build-system:
description: 'If provided, only the specified build systems will be instrumented (allowed values are `gradle` and `maven`). Otherwise every Java process will be instrumented.'
required: false
# deprecated inputs
service-name:
description: 'Deprecated, alias for service'
required: true
deprecationMessage: 'service-name input is deprecated, please use service instead'
api-key:
description: 'Deprecated, alias for api_key'
required: true
deprecationMessage: 'api-key input is deprecated, please use api_key instead'
runs:
using: "composite"
steps:
- name: Set GitHub Path
run: echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH
shell: bash
env:
GITHUB_ACTION_PATH: ${{ github.action_path }}
- name: Download and run configuration script
id: run-configuration-script
run: |
mkdir -p $GITHUB_WORKSPACE/.datadog
if mkdir -p /github/workspace >/dev/null 2>&1; then
# See https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action#accessing-files-created-by-a-container-action
# When running a Docker container action, the Github workspace is available at a hard-coded path of /github/workspace
# When running a "regular", the workspace path varies.
# The symlink trick below is needed to make the same path /github/workspace/.datadog available for all types of actions
ln -s $GITHUB_WORKSPACE/.datadog /github/workspace/.datadog
export DD_TRACER_FOLDER=/github/workspace/.datadog
else
export DD_TRACER_FOLDER=$GITHUB_WORKSPACE/.datadog
fi
script_filepath="install_test_visibility.sh"
if command -v curl >/dev/null 2>&1; then
curl -Lo "$script_filepath" "$INSTALLATION_SCRIPT_URL"
elif command -v wget >/dev/null 2>&1; then
wget -O "$script_filepath" "$INSTALLATION_SCRIPT_URL"
else
>&2 echo "Error: Neither wget nor curl is installed."
return 1
fi
if ! echo "$INSTALLATION_SCRIPT_CHECKSUM $script_filepath" | sha256sum --quiet -c -; then
return 1
fi
chmod +x $script_filepath
./$script_filepath >> "$GITHUB_ENV"
shell: bash
env:
DD_CIVISIBILITY_INSTRUMENTATION_LANGUAGES: ${{ inputs.languages }}
DD_API_KEY: ${{ inputs.api-key != '' && inputs.api-key || inputs.api_key }}
DD_SITE: ${{ inputs.site }}
DD_SET_TRACER_VERSION_DOTNET: ${{ inputs.dotnet-tracer-version }}
DD_SET_TRACER_VERSION_JAVA: ${{ inputs.java-tracer-version }}
DD_SET_TRACER_VERSION_JS: ${{ inputs.js-tracer-version }}
DD_SET_TRACER_VERSION_PYTHON: ${{ inputs.python-tracer-version }}
DD_INSTRUMENTATION_BUILD_SYSTEM_JAVA: ${{ inputs.java-instrumented-build-system }}
INSTALLATION_SCRIPT_URL: https://install.datadoghq.com/scripts/install_test_visibility_v1.sh
INSTALLATION_SCRIPT_CHECKSUM: a1edc11da0d00084c05525151aca5d377f86e3461c94d84f6172b760fa61e125
- name: Propagate optional site input to environment variable
if: "${{ inputs.site != '' }}"
run: |
echo "DD_SITE=${{ inputs.site }}" >> "$GITHUB_ENV"
shell: bash
- name: Propagate service name and API key from inputs to environment variables
run: |
echo "DD_SERVICE=${{ inputs.service-name != '' && inputs.service-name || inputs.service }}" >> "$GITHUB_ENV"
echo "DD_API_KEY=${{ inputs.api-key != '' && inputs.api-key || inputs.api_key }}" >> "$GITHUB_ENV"
echo "DD_CIVISIBILITY_AUTO_INSTRUMENTATION_PROVIDER=github" >> "$GITHUB_ENV"
shell: bash
- name: Print summary
run: |
echo "---" >> $GITHUB_STEP_SUMMARY
echo '<a target="_blank" title="Datadog Test Visibility" href="https://docs.datadoghq.com/tests/"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/DataDog/test-visibility-github-action/main/logos/dd_logo_h_white.svg"><img width="200" alt="Datadog Test Visibility" src="https://raw.githubusercontent.com/DataDog/test-visibility-github-action/main/logos/dd_logo_h_rgb.svg"></picture></a>' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Installed Test Visibility libraries:" >> $GITHUB_STEP_SUMMARY
if [ ! -z "$DD_TRACER_VERSION_DOTNET" ]; then
echo "- __.NET:__ $DD_TRACER_VERSION_DOTNET" >> $GITHUB_STEP_SUMMARY
fi
if [ ! -z "$DD_TRACER_VERSION_JAVA" ]; then
echo "- __Java:__ $DD_TRACER_VERSION_JAVA" >> $GITHUB_STEP_SUMMARY
fi
if [ ! -z "$DD_TRACER_VERSION_JS" ]; then
echo "- __JS:__ $DD_TRACER_VERSION_JS" >> $GITHUB_STEP_SUMMARY
fi
if [ ! -z "$DD_TRACER_VERSION_PYTHON" ]; then
echo "- __Python:__ $DD_TRACER_VERSION_PYTHON" >> $GITHUB_STEP_SUMMARY
fi
echo "---" >> $GITHUB_STEP_SUMMARY
shell: bash