-
Notifications
You must be signed in to change notification settings - Fork 30
140 lines (120 loc) · 6.41 KB
/
test_tool_behaviour.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
name: Simulate Update Tool Behavior
on:
workflow_dispatch:
inputs:
activeDistribution:
description: 'Active distribution while testing'
required: true
activeTool:
description: 'Active tool version at the beginning'
required: true
testOnDev:
description: 'Test on dev branch'
required: false
default: false
inputCommand:
description: 'Input command to be tested'
required: false
default: 'bal dist list'
jobs:
ballerina-update-tool-test:
name: Simulate Ballerina Update Tool Behavior
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Set env variables Ubuntu/Mac
if: matrix.os != 'windows-latest'
run: |
echo "activeDistribution=${{ github.event.inputs.activeDistribution }}" >> $GITHUB_ENV
echo "activeTool=${{ github.event.inputs.activeTool }}" >> $GITHUB_ENV
if [ "${{ github.event.inputs.testOnDev }}" = "true" ]; then
echo "env=dist-dev.ballerina.io" >> $GITHUB_ENV
echo "BALLERINA_DEV_UPDATE=true" >> $GITHUB_ENV
else
echo "env=dist.ballerina.io" >> $GITHUB_ENV
fi
- name: Install unzip on Linux
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install -y unzip
- name: Install unzip on macOS
if: matrix.os == 'macos-latest'
run: brew install unzip
- name: Download and unzip Ballerina Ubuntu/Mac
if: matrix.os != 'windows-latest'
run: |
wget "https://$env/downloads/$activeDistribution/ballerina-$activeDistribution-swan-lake.zip"
unzip "ballerina-$activeDistribution-swan-lake.zip"
env:
JAVA_HOME: /usr/lib/jvm/default-jvm
JAVA_OPTS: -DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true
- name: Download and unzip Ballerina Windows
if: matrix.os == 'windows-latest'
shell: cmd
run: |
if ${{ github.event.inputs.testOnDev }}=="true" (
curl -o "ballerina-${{ github.event.inputs.activeDistribution }}-swan-lake.zip" "https://dist-dev.ballerina.io/downloads/${{ github.event.inputs.activeDistribution }}/ballerina-${{ github.event.inputs.activeDistribution }}-swan-lake.zip"
) else (
curl -o "ballerina-${{ github.event.inputs.activeDistribution }}-swan-lake.zip" "https://dist.ballerina.io/downloads/${{ github.event.inputs.activeDistribution }}/ballerina-${{ github.event.inputs.activeDistribution }}-swan-lake.zip"
)
PowerShell -Command "Expand-Archive -Path 'ballerina-${{ github.event.inputs.activeDistribution }}-swan-lake.zip'"
- name: Download and unzip Update Tool Ubuntu/Mac
if: matrix.os != 'windows-latest'
run: |
wget "https://github.com/ballerina-platform/ballerina-update-tool/releases/download/v$activeTool/ballerina-command-$activeTool.zip"
unzip "ballerina-command-$activeTool.zip"
- name: Download and unzip Update Tool Windows
if: matrix.os == 'windows-latest'
shell: cmd
run: |
curl -fL -o "ballerina-command-windows-${{ github.event.inputs.activeTool }}.zip" "https://github.com/ballerina-platform/ballerina-update-tool/releases/download/v${{ github.event.inputs.activeTool }}/ballerina-command-windows-${{ github.event.inputs.activeTool }}.zip"
PowerShell -Command "Expand-Archive -Path 'ballerina-command-windows-${{ github.event.inputs.activeTool }}.zip'"
- name: Replace existing lib and bin directories Ubuntu/Mac
if: matrix.os != 'windows-latest'
run: |
rm -rf "ballerina-$activeDistribution-swan-lake/lib"
rm -rf "ballerina-$activeDistribution-swan-lake/bin"
mv "ballerina-command-$activeTool/lib" "ballerina-$activeDistribution-swan-lake/"
mv "ballerina-command-$activeTool/bin" "ballerina-$activeDistribution-swan-lake/"
- name: Replace existing lib and bin directories Windows
if: matrix.os == 'windows-latest'
shell: cmd
run: |
tree
dir
rmdir /s /q "ballerina-${{ github.event.inputs.activeDistribution }}-swan-lake\ballerina-${{ github.event.inputs.activeDistribution }}-swan-lake\lib"
rmdir /s /q "ballerina-${{ github.event.inputs.activeDistribution }}-swan-lake\ballerina-${{ github.event.inputs.activeDistribution }}-swan-lake\bin"
move "ballerina-command-windows-${{ github.event.inputs.activeTool }}\ballerina-command-windows-${{ github.event.inputs.activeTool }}\lib" "ballerina-${{ github.event.inputs.activeDistribution }}-swan-lake\ballerina-${{ github.event.inputs.activeDistribution }}-swan-lake\"
move "ballerina-command-windows-${{ github.event.inputs.activeTool }}\ballerina-command-windows-${{ github.event.inputs.activeTool }}\bin" "ballerina-${{ github.event.inputs.activeDistribution }}-swan-lake\ballerina-${{ github.event.inputs.activeDistribution }}-swan-lake\"
- name: Set Ballerina path variable Ubuntu/Mac
if: matrix.os != 'windows-latest'
run: |
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
echo "PATH=$PATH:/home/runner/work/ballerina-update-tool/ballerina-update-tool/ballerina-$activeDistribution-swan-lake/bin" >> $GITHUB_ENV
else
echo "PATH=$PATH:/Users/runner/work/ballerina-update-tool/ballerina-update-tool/ballerina-$activeDistribution-swan-lake/bin" >> $GITHUB_ENV
fi
- name: Set Ballerina path variable Windows
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
echo "D:\a\ballerina-update-tool\ballerina-update-tool\ballerina-${{ github.event.inputs.activeDistribution }}-swan-lake\ballerina-${{ github.event.inputs.activeDistribution }}-swan-lake\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Run `bal -v`
run: |
bal -v
- name: Run `bal dist list`
run: bal dist list
- name: Run input command
run: ${{ github.event.inputs.inputCommand }}
- name: Run `bal -v` after command execution
run: bal -v
- name: Run `bal dist list` after command execution
run: bal dist list