-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
121 lines (100 loc) · 5.53 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
# Copyright (C) 2020-present Cumulocity GmbH
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
#
# Use of this action implies agreement to the terms for using Apama Community Edition - http://www.apamacommunity.com/terms-conditions/
name: 'Setup Apama'
description: 'Install Apama Community Edition and add it to your GitHub Actions environment'
author: Apama
inputs:
apama-version:
description: 'The 4 digit version to install from https://download.cumulocity.com/Apama, e.g. 10.5.3.2'
required: true
runs:
using: "composite"
steps:
- name: Install Apama Community Edition
shell: bash
run: |
echo Use of this action implies agreement to the terms for using Apama Community Edition
echo See: https://cumulocity.com/docs/legal-notices/license-terms-and-conditions/
echo
APAMA_CACHE_TAR=~/cached-apama-installation.tar
if [[ ${{runner.os}} = Windows ]]; then
_SAG_INSTALL_PATH=c:\\SoftwareAG
DOWNLOAD_PLATFORM=amd64_win
else
_SAG_INSTALL_PATH=/opt/softwareag
DOWNLOAD_PLATFORM=amd64_linux
fi
if [[ -f $APAMA_CACHE_TAR ]]; then
echo Unpacking Apama installation from cache at $APAMA_CACHE_TAR
mkdir $_SAG_INSTALL_PATH
cd $_SAG_INSTALL_PATH
time tar -xf $APAMA_CACHE_TAR
# Check it unpacked correctly
ls $_SAG_INSTALL_PATH/Apama
else
echo No installation found in cache $APAMA_CACHE_TAR
# Cache miss - need to install it
mkdir ../apama-installer
cd ../apama-installer
DOWNLOAD_URL=https://downloads.apamacommunity.com/apama/${{ inputs.apama-version }}/apama_${{ inputs.apama-version }}_$DOWNLOAD_PLATFORM.zip
echo Downloading from $DOWNLOAD_URL
# First use head to check the URL is valid (gives a more helpful message if it doesn't)
curl --retry 2 --head $DOWNLOAD_URL
curl --retry 2 --output apama-installer.zip $DOWNLOAD_URL
unzip -q apama-installer.zip
mv apama_*/* ./
cat > apama-installer-script.txt << EOF
LicenseAgree=Accept
InstallProducts=e2ei/11/.latest/Apama/PAMServer
PAM.Work.Directory.ID=__VERSION1__,$_SAG_INSTALL_PATH/apama-work
InstallDir=$_SAG_INSTALL_PATH
sagInstallerLogFile=softwareag-installer.log
imageFile=data/SAGImage.zip
EOF
# Need to escape backslashes as it's effectively a properties file
sed -i 's/\\/\\\\/g' apama-installer-script.txt
echo Running installer with script:
cat apama-installer-script.txt
./install -readScript apama-installer-script.txt -console -scriptErrorInteract no
# Double-check that it was installed
ls $_SAG_INSTALL_PATH/Apama/bin > /dev/null
# Archive a pristine copy of the installation for the cache (before running any tests);
# no need to compress as the cache already does that
cd $_SAG_INSTALL_PATH
tar -cf $APAMA_CACHE_TAR *
fi
cd ~
# Until Apama 10.7 we need to explicitly enable color from GitHub Actions
# (and disable colorama on windows which would replace the escape codes)
echo PYSYS_COLOR=true >> $GITHUB_ENV
echo PYSYS_DISABLE_COLORAMA=true >> $GITHUB_ENV
# Once installed, copy the entire apama environment into the GH Actions env so it can be used in any type of
# shell (bash/cmd/PS etc). We also set an extra env var APAMA_PYSYS so user can run pysys from any shell.
if [[ ${{runner.os}} = Windows ]]; then
echo "APAMA_PYSYS=pysys.cmd" >> $GITHUB_ENV
echo "APAMA_HOME=`cygpath --windows $_SAG_INSTALL_PATH/Apama`" >> $GITHUB_ENV
# For Windows we need to do it all in a separate (cmd) step otherwise extra vars from Git Bash will leak in
else
echo "APAMA_PYSYS=pysys" >> $GITHUB_ENV
. $_SAG_INSTALL_PATH/Apama/bin/apama_env
env | sort >> apama.env
# This will replace the environment to point at Apama rather than GH Actions pre-installed tools, which ensures
# the right version of Ant/Java etc is used
cat apama.env >> $GITHUB_ENV
fi
- name: Setup Apama environment on Windows
shell: python
run: |
# Ideally we'd just run this in a cmd shell, but can't since it wouldn't work on Linux, and GH composite
# action steps don't yet support "if".
# Can't do this as part of the bash shell above, as Windows Git Bash pollutes the PATH environment.
# Python to the rescue!
import os
if os.name == 'nt': # Windows
print('Adding apama_env.bat environment to GITHUB_ENV')
cmd = r'cmd /c "%APAMA_HOME%\bin\apama_env.bat && set >> %GITHUB_ENV%"'
os.system(cmd)