-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaction.yml
163 lines (151 loc) · 7.68 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
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", "ruby", "go" (multiple languages can be specified as a space-separated list).'
required: true
api_key:
description: 'Datadog API key. Can be found at https://app.datadoghq.com/organization-settings/api-keys'
required: true
site:
description: 'Datadog site (optional). See https://docs.datadoghq.com/getting_started/site for more information about sites.'
required: false
default: datadoghq.com
service:
description: 'The name of the service or library being tested.'
required: false
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
ruby-tracer-version:
description: 'The version of datadog-ci Ruby gem to use (optional). Defaults to the latest release.'
required: false
go-tracer-version:
description: 'The version of Orchestrion automatic compile-time instrumentation of Go code (https://github.com/datadog/orchestrion) 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: false
deprecationMessage: 'service-name input is deprecated, please use service instead'
api-key:
description: 'Deprecated, alias for api_key'
required: false
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 [ "$GITHUB_WORKSPACE" != "/github/workspace" ] && 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
if [ ! -e /github/workspace/.datadog ]; then
ln -s $GITHUB_WORKSPACE/.datadog /github/workspace/.datadog
fi
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."
exit 1
fi
if command -v sha256sum >/dev/null 2>&1; then
if ! echo "$INSTALLATION_SCRIPT_CHECKSUM $script_filepath" | sha256sum --quiet -c -; then
exit 1
fi
elif command -v shasum >/dev/null 2>&1; then
if ! echo "$INSTALLATION_SCRIPT_CHECKSUM $script_filepath" | shasum --quiet -a 256 -c -; then
exit 1
fi
else
>&2 echo "Error: Neither sha256sum nor shasum is installed."
exit 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_SET_TRACER_VERSION_RUBY: ${{ inputs.ruby-tracer-version }}
DD_SET_TRACER_VERSION_GO: ${{ inputs.go-tracer-version }}
DD_INSTRUMENTATION_BUILD_SYSTEM_JAVA: ${{ inputs.java-instrumented-build-system }}
INSTALLATION_SCRIPT_URL: https://install.datadoghq.com/scripts/install_test_visibility_v7.sh
INSTALLATION_SCRIPT_CHECKSUM: 2554982c134b97848dc1695651b66ed54633d2a0d98b665a4a452ad916cf6fde
- name: Propagate optional site input to environment variable
if: "${{ inputs.site != '' }}"
run: |
echo "DD_SITE=${{ inputs.site }}" >> "$GITHUB_ENV"
shell: bash
- name: Propagate optional service input to environment variable
if: "${{ inputs.service != '' || inputs.service-name != '' }}"
run: |
echo "DD_SERVICE=${{ inputs.service-name != '' && inputs.service-name || inputs.service }}" >> "$GITHUB_ENV"
shell: bash
- name: Propagate API key from input to environment variables and set provider
run: |
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
if [ ! -z "$DD_TRACER_VERSION_RUBY" ]; then
echo "- __Ruby:__ $DD_TRACER_VERSION_RUBY" >> $GITHUB_STEP_SUMMARY
fi
if [ ! -z "$DD_TRACER_VERSION_GO" ]; then
echo "- __Go:__ $DD_TRACER_VERSION_GO" >> $GITHUB_STEP_SUMMARY
fi
echo "---" >> $GITHUB_STEP_SUMMARY
shell: bash