Skip to content

Merge pull request #1531 from tediousjs/dependabot/npm_and_yarn/seman… #76

Merge pull request #1531 from tediousjs/dependabot/npm_and_yarn/seman…

Merge pull request #1531 from tediousjs/dependabot/npm_and_yarn/seman… #76

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-latest
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-latest
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: ubuntu-latest
needs:
- commitlint
- codelint
env:
MSSQL_PASSWORD: 'yourStrong(!)Password'
IMAGE_NAME: ${{ matrix.sql-version == 'edge' && 'azure-sql-edge' || 'mssql/server' }}
IMAGE_TAG: ${{ matrix.sql-version == 'edge' && 'latest' || format('{0}-latest', matrix.sql-version) }}
strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
sql-version: [2017, 2019, 2022]
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm clean-install
- name: Run unit tests
run: npm run test-unit
- name: Setup docker cache
id: cache-docker
uses: actions/cache@v3
with:
path: .docker
key: docker-cache-${{ runner.os }}-${{ matrix.sql-version }}-latest
- name: Save docker image
if: steps.cache-docker.outputs.cache-hit != 'true'
run: |
mkdir .docker
docker pull "mcr.microsoft.com/$IMAGE_NAME:$IMAGE_TAG"
docker image save "mcr.microsoft.com/$IMAGE_NAME:$IMAGE_TAG" -o "./.docker/${{ matrix.sql-version }}.tar"
- name: Load docker image
if: steps.cache-docker.outputs.cache-hit == 'true'
run: docker image load -i "./.docker/${{ matrix.sql-version }}.tar"
- name: Start docker container
run: docker run --name mssql -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=$MSSQL_PASSWORD" -p 1433:1433 -d "mcr.microsoft.com/$IMAGE_NAME:$IMAGE_TAG"
- name: Store test config
run: echo "{\"user\":\"sa\",\"password\":\"$MSSQL_PASSWORD\",\"server\":\"localhost\",\"port\":1433,\"database\":\"master\",\"options\":{\"trustServerCertificate\":true}}" > ./test/.mssql.json
- name: Wait for database to be ready
run: |
set +e
ATTEMPT=0
while [ $ATTEMPT -le 10 ]; do
ATTEMPT=$(( ATTEMPT + 1 ))
docker exec mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U "sa" -P "$MSSQL_PASSWORD" -q 'SELECT 1;' | grep '1 rows affected'
if [ $? -eq 0 ]; then
break
fi
sleep 1
done
- 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
- name: Stop container
if: ${{ always() }}
run: docker rm -f -v mssql
test-windows:
name: Run tests (Windows)
needs:
- commitlint
- codelint
- test-linux
runs-on: 'windows-latest'
env:
MSSQL_PASSWORD: 'yourStrong(!)Password'
strategy:
matrix:
arch: [x64, x86]
node-version: [14.x, 16.x, 18.x]
sql-version: [2017, 2019, 2022]
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
architecture: ${{ matrix.arch }}
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm clean-install
- name: Run unit tests
run: npm run test-unit
- name: Setup SQL Server
uses: potatoqualitee/[email protected]
with:
install: sqlengine
sa-password: ${{ env.MSSQL_PASSWORD }}
version: ${{ matrix.sql-version }}
- name: Store test config
shell: bash
run: echo "{\"user\":\"sa\",\"password\":\"$MSSQL_PASSWORD\",\"server\":\"localhost\",\"port\":1433,\"database\":\"master\",\"options\":{\"trustServerCertificate\":true}}" > ./test/.mssql.json
- name: Wait for database to be ready
shell: bash
run: |
set +e
ATTEMPT=0
while [ $ATTEMPT -le 10 ]; do
ATTEMPT=$(( ATTEMPT + 1 ))
sqlcmd -S localhost -U "sa" -P "$MSSQL_PASSWORD" -q 'SELECT 1;' | grep '1 rows affected'
if [ $? -eq 0 ]; then
break
fi
sleep 1
done
- name: Run tedious tests
run: npm run test-tedious
- name: Run cli tests
run: npm run test-cli
- name: Install msnodesqlv8
if: ${{ matrix.sql-version != '2022' }}
run: npm install --no-save msnodesqlv8@^2
- name: Run msnodesqlv8 tests
if: ${{ matrix.sql-version != '2022' }}
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-latest
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