-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1502 from dhensby/pulls/auto-release
Add automated release workflows
- Loading branch information
Showing
8 changed files
with
19,838 additions
and
2,387 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
extends: | ||
- '@commitlint/config-conventional' | ||
rules: | ||
body-max-line-length: [0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "npm" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,225 @@ | ||
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 | ||
if: ${{ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
branches: | ||
- master | ||
plugins: | ||
- '@semantic-release/commit-analyzer' | ||
- '@semantic-release/release-notes-generator' | ||
- '@semantic-release/npm' | ||
- '@semantic-release/github' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.