Skip to content

Commit

Permalink
Support installation of sqlcmd
Browse files Browse the repository at this point in the history
  • Loading branch information
andyundso committed Jul 27, 2024
1 parent d08a956 commit b1680aa
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Continuous Integration

on:
pull_request:
push:

permissions:
contents: read

jobs:
test:
name: Tests
strategy:
matrix:
os:
# ignore ARM64 flavours
- macos-12-large
- macos-13-large
- macos-14-large
- ubuntu-20.04
- ubuntu-22.04
- ubuntu-24.04
- windows-2019
- windows-2022

runs-on: ${{ matrix.os }}
steps:
# cloning into "root" does not work when trying to call the action from itself
# inspired by Microsoft: https://github.com/microsoft/action-python/blob/c8ec939994d7ed2ec77b7bbe59ed5f5b72fb5607/.github/workflows/test.yml#L21
- name: Checkout
uses: actions/checkout@v4
with:
path: action
clean: true

- name: Run Action
uses: ./action
with:
components: sqlcmd

- name: Run tests
run: |
action/test.ps1
shell: pwsh
19 changes: 19 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Setup MSSQL"
branding:
icon: "database"
color: "yellow"
description: "Installs an MSSQL server and client"
inputs:
components:
description: "The components to install"
required: true
runs:
using: "composite"
steps:
- shell: pwsh
run: |
$params = @{
Install = ("${{ inputs.install }}" -split ",").Trim()
}
${{ github.action_path }}/install.ps1 @params
9 changes: 9 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
if ("sqlcmd" -in $Install) {
if ($ismacos) {
Write-Output "Installing sqlcmd tools"
brew install sqlcmd
}

# Linux and Windows runner already contain sqlclient tools
Write-Output "sqlclient tools are installed"
}
6 changes: 6 additions & 0 deletions test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if (Get-Command sqlcmd -ErrorAction SilentlyContinue) {
Write-Output "sqlcmd command exists."
} else {
Write-Output "sqlcmd command does not exist."
exit 1
}

0 comments on commit b1680aa

Please sign in to comment.