Skip to content

Commit 56c5396

Browse files
committed
Support installation of sqlcmd
1 parent d08a956 commit 56c5396

File tree

4 files changed

+83
-0
lines changed

4 files changed

+83
-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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
# Linux and Windows runner already contain sqlclient tools
13+
Write-Output "sqlclient tools are installed"
14+
}

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)