Skip to content

Add Agent writer agent #390

Add Agent writer agent

Add Agent writer agent #390

Workflow file for this run

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