Skip to content

Commit 4a36723

Browse files
committed
Support installation of sqlcmd
1 parent d08a956 commit 4a36723

File tree

4 files changed

+102
-0
lines changed

4 files changed

+102
-0
lines changed

.github/workflows/ci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Continuous Integration
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
test:
12+
name: Tests
13+
strategy:
14+
matrix:
15+
os:
16+
# ignore ARM64 flavours
17+
- macos-12-large
18+
- macos-13-large
19+
- macos-14-large
20+
- ubuntu-20.04
21+
- ubuntu-22.04
22+
- ubuntu-24.04
23+
- windows-2019
24+
- windows-2022
25+
26+
runs-on: ${{ matrix.os }}
27+
steps:
28+
# cloning into "root" does not work when trying to call the action from itself
29+
# inspired by Microsoft: https://github.com/microsoft/action-python/blob/c8ec939994d7ed2ec77b7bbe59ed5f5b72fb5607/.github/workflows/test.yml#L21
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
with:
33+
path: action
34+
clean: true
35+
36+
- name: Run Action
37+
uses: ./action
38+
with:
39+
components: sqlcmd
40+
41+
- name: Run tests
42+
run: |
43+
action/test.ps1
44+
shell: pwsh

action.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: "Setup MSSQL"
2+
branding:
3+
icon: "database"
4+
color: "yellow"
5+
description: "Installs an MSSQL server and client"
6+
inputs:
7+
components:
8+
description: "The components to install"
9+
required: true
10+
runs:
11+
using: "composite"
12+
steps:
13+
- shell: pwsh
14+
run: |
15+
$params = @{
16+
Components = ("${{ inputs.components }}" -split ",").Trim()
17+
}
18+
19+
${{ github.action_path }}/install.ps1 @params

install.ps1

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
param (
2+
[ValidateSet("sqlcmd")]
3+
[string[]]$Components
4+
)
5+
6+
if ("sqlcmd" -in $Components) {
7+
if ($IsMacOS) {
8+
Write-Output "Installing sqlcmd tools"
9+
brew install sqlcmd
10+
}
11+
12+
if ($IsLinux) {
13+
$osRelease = Get-Content -Path "/etc/os-release" | Out-String
14+
$osRelease -match 'VERSION_ID="(\d+\.\d+)"'
15+
$version = $matches[1]
16+
17+
Write-Debug $version
18+
19+
if ($version -eq "24.04") {
20+
# for maintenance reasons, sqlcmd has been removed from the runner image
21+
# but a dedicated build is also not yet available, so we are using the Ubuntu 22.04 build
22+
Write-Output "Installing sqlcmd tools"
23+
24+
$DownloadPath = "/tmp/sqlcmd.deb"
25+
Invoke-WebRequest "https://packages.microsoft.com/ubuntu/22.04/prod/pool/main/s/sqlcmd/sqlcmd_1.5.0-1_jammy_all.deb" -OutFile $DownloadPath
26+
& dpkg -i $DownloadPath
27+
Remove-Item $DownloadPath
28+
}
29+
}
30+
31+
# Linux and Windows runner already contain sqlclient tools
32+
Write-Output "sqlclient tools are installed"
33+
}

test.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
if (Get-Command sqlcmd -ErrorAction SilentlyContinue) {
2+
Write-Output "sqlcmd command exists."
3+
} else {
4+
Write-Output "sqlcmd command does not exist."
5+
exit 1
6+
}

0 commit comments

Comments
 (0)