-
Notifications
You must be signed in to change notification settings - Fork 7
139 lines (124 loc) · 5.87 KB
/
actions_tests.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
name: AI Actions tests
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
get-changed-files:
# Exports a comma-separated list of changed files for later introspection.
runs-on: ubuntu-latest
outputs:
changed_files: ${{ steps.changed_files.outputs.files }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Get changed files
id: changed_files
run: |
echo "Changed files:"
git fetch origin ${{ github.event.pull_request.base.ref }}
changed_files=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }} | tr '\n' ',')
changed_files=${changed_files%,} # removes the trailing comma
echo "$changed_files"
echo "files=$changed_files" >> $GITHUB_OUTPUT
run-command:
needs: get-changed-files
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
timeout-minutes: 60 # timeouts after 1h
# TODO: Enable environment once we get the flows running without review rulesets.
# environment: staging # configure it in GH Settings -> Environments
env:
# Set it to "latest" if you want the bleeding edge.
# ACTION_SERVER_VERSION: {{ vars.ACTION_SERVER_VERSION }}
ACTION_SERVER_VERSION: "latest" # not relying yet on evnironments
steps:
- name: Checkout repository
uses: actions/checkout@v3
# TODO: Enable caching once we can invalidate the keys on "latest" or once we can
# take into use set environments without rulesets.
# - name: Cache action-server executable on *nix OS
# if: runner.os != 'Windows'
# id: cache-action-server-nix
# uses: actions/cache@v3
# with:
# path: /usr/local/bin/action-server
# key: nix-action-server-${{ env.ACTION_SERVER_VERSION }}
# restore-keys: |
# nix-action-server-
- name: Download Action Server executable for *nix OS
if: runner.os != 'Windows'
run: |
echo "Downloading latest Action Server..."
system=$(uname -s)
case ${system} in
Darwin*) url=https://cdn.sema4.ai/action-server/releases/${{ env.ACTION_SERVER_VERSION }}/macos64/action-server;;
Linux*) url=https://cdn.sema4.ai/action-server/releases/${{ env.ACTION_SERVER_VERSION }}/linux64/action-server;;
*) echo "Invalid platform '$system' detected!"; exit 1;
esac
curl -L -o /usr/local/bin/action-server $url
chmod +x /usr/local/bin/action-server
echo "Action Server version: $(action-server version)"
shell: bash
- name: Build package metadata on *nix OS
if: runner.os != 'Windows'
run: |
echo "Building metadata for every affected Action Package..."
changed_files="${{ needs.get-changed-files.outputs.changed_files }}"
for dir in $(find actions -type d -maxdepth 1); do
if [ ! -f "$dir/package.yaml" ]; then
continue # skips non-packages
fi
if ! echo "$changed_files" | grep -q "$dir"; then
continue # skips unaffected packages
fi
echo "Building metadata over Action Package: $dir"
# Tried to run this in parallel, but we get bottlenecked by RCC locks.
(pushd $dir && action-server package metadata && popd)
done
shell: bash
# TODO: Enable caching once we can invalidate the keys on "latest" or once we can
# take into use set environments without rulesets.
# - name: Cache action-server executable on Windows OS
# if: runner.os == 'Windows'
# id: cache-action-server-windows
# uses: actions/cache@v3
# with:
# path: $Env:TEMP\action-server.exe
# key: windows-action-server-${{ env.ACTION_SERVER_VERSION }}
# restore-keys: |
# windows-action-server-
- name: Download Action Server executable for Windows OS
if: runner.os == 'Windows'
run: |
Write-Output "Downloading latest Action Server..."
Invoke-WebRequest -Uri https://cdn.sema4.ai/action-server/releases/${{ env.ACTION_SERVER_VERSION }}/windows64/action-server.exe -OutFile $Env:TEMP\action-server.exe
[Environment]::SetEnvironmentVariable('PATH', $Env:TEMP + ';' + [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Process), [EnvironmentVariableTarget]::Process)
$version = action-server.exe version
Write-Output "Action Server version: $version"
shell: pwsh
- name: Build package metadata on Windows OS
if: runner.os == 'Windows'
run: |
Write-Output "Building metadata for every affected Action Package..."
$changed_files = "${{ needs.get-changed-files.outputs.changed_files }}"
[Environment]::SetEnvironmentVariable('PATH', $Env:TEMP + ';' + [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Process), [EnvironmentVariableTarget]::Process)
Get-ChildItem actions -Directory | ForEach-Object {
if (-not (Test-Path "$($_.FullName)\package.yaml")) {
# Yes, `return`, not `continue` (as it would break the loop).
return # skips non-packages
}
if (-not $changed_files.Contains("actions/$($_.Name)")) { # linux path
return # skips unaffected packages
}
Write-Output "Building metadata over Action Package: $($_.FullName)"
Set-Location -Path $_.FullName
action-server.exe package metadata
if ($LASTEXITCODE -ne 0) {
Write-Output "Metadata building failed in: $($_.FullName)"
exit 1
}
Set-Location -Path $Env:GITHUB_WORKSPACE
}
shell: pwsh