Skip to content

ci: add dependabot config for github actions #260

ci: add dependabot config for github actions

ci: add dependabot config for github actions #260

Workflow file for this run

name: Lint, Test & Release
on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:
permissions:
contents: read
jobs:
commitlint:
name: Lint commits
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'npm'
- name: Install dependencies
run: npm clean-install
- name: Lint commit
if: github.event_name == 'push'
run: npx commitlint --from HEAD~1 --to HEAD --verbose
- name: Lint commits
if: github.event_name == 'pull_request'
run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose
codelint:
name: Lint code
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'npm'
- name: Install dependencies
run: npm clean-install
- name: Lint code
run: npm run lint
test-linux:
name: Run tests
runs-on: ${{ matrix.os }}
services:
sqlserver:
image: mcr.microsoft.com/${{ matrix.sqlserver == 'edge' && 'azure-sql-edge' || 'mssql/server' }}:${{ matrix.sqlserver == 'edge' && 'latest' || format('{0}-latest', matrix.sqlserver ) }}
ports:
- 1433:1433
env:
ACCEPT_EULA: Y
MSSQL_SA_PASSWORD: ${{ env.MSSQL_PASSWORD }}
needs:
- commitlint
- codelint
env:
MSSQL_PASSWORD: 'yourStrong(!)Password'
strategy:
matrix:
os: [ubuntu-22.04]
node: [16.x, 18.x, 20.x]
sqlserver: [2017, 2019, 2022]
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'npm'
- name: Install dependencies
run: npm clean-install
- name: Run unit tests
run: npm run test-unit
- name: Store test config
run: echo "{\"user\":\"sa\",\"password\":\"$MSSQL_PASSWORD\",\"server\":\"localhost\",\"port\":1433,\"database\":\"master\",\"options\":{\"trustServerCertificate\":true}}" > ./test/.mssql.json
- name: Run tedious tests
run: npm run test-tedious
- name: Run cli tests
run: npm run test-cli
# The msnodesqlv8 tests fail with a segmentation fault
# - name: Install OBDC 17 driver
# run: |
# sudo curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
# sudo curl -o /etc/apt/sources.list.d/mssql-release.list https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list
# sudo apt-get update
# sudo apt-get install -y msodbcsql17
# env:
# ACCEPT_EULA: Y
# - name: Install msnodesqlv8
# run: npm install --no-save msnodesqlv8@^2
# - name: Run msnodesqlv8 tests
# run: npm run test-msnodesqlv8
test-windows:
name: Run tests
needs:
- commitlint
- codelint
- test-linux
runs-on: ${{ matrix.os }}
env:
MSSQL_PASSWORD: 'yourStrong(!)Password'
strategy:
matrix:
os: [windows-2019, windows-2022]
node: [16.x, 18.x, 20.x]
sqlserver: [2008, 2012, 2014, 2016, 2017, 2019, 2022]
# These sqlserver versions don't work on windows-2022 (at the moment)
exclude:
- os: windows-2022
sqlserver: 2008
- os: windows-2022
sqlserver: 2012
- os: windows-2022
sqlserver: 2014
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'npm'
- name: Install dependencies
run: npm clean-install
- name: Run unit tests
run: npm run test-unit
- name: Setup SQL Server
uses: tediousjs/setup-sqlserver@v1
with:
sqlserver-version: ${{ matrix.sqlserver }}
sa-password: ${{ env.MSSQL_PASSWORD }}
native-client-version: 11
- name: Store test config
shell: bash
run: echo "{\"user\":\"sa\",\"password\":\"$MSSQL_PASSWORD\",\"server\":\"localhost\",\"port\":1433,\"database\":\"master\",\"requestTimeout\":30000,\"options\":{\"abortTransactionOnError\":true,\"encrypt\":false}}" > ./test/.mssql.json
- name: Run tedious tests
run: npm run test-tedious
- name: Run cli tests
run: npm run test-cli
- name: Install msnodesqlv8
run: npm install --no-save msnodesqlv8@^2
- name: Run msnodesqlv8 tests
run: npm run test-msnodesqlv8
release:
name: Release
concurrency: release
if: ${{ github.repository_owner == 'tediousjs' && github.event_name == 'push' && github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-22.04
needs:
- commitlint
- codelint
- test-linux
- test-windows
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"
cache: 'npm'
- name: Install dependencies
run: npm clean-install
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
run: npm audit signatures
- name: Release
env:
NPM_CONFIG_PROVENANCE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release