2021-10-13 16:18:02 +02:00
|
|
|
---
|
2020-07-23 23:02:59 +02:00
|
|
|
name: Build
|
|
|
|
|
|
|
|
on: push
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
cloc:
|
2021-10-13 16:18:02 +02:00
|
|
|
name: CLOC
|
|
|
|
runs-on: ubuntu-20.04
|
2020-07-23 23:02:59 +02:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
2021-05-17 18:46:54 +02:00
|
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
2020-07-23 23:02:59 +02:00
|
|
|
|
|
|
|
- name: Set up cloc
|
|
|
|
run: |
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get -y install cloc
|
|
|
|
|
|
|
|
- name: Print lines of code
|
|
|
|
run: cloc --include-lang TypeScript,JavaScript,HTML,Sass,CSS --vcs git
|
|
|
|
|
|
|
|
build:
|
2021-10-13 16:18:02 +02:00
|
|
|
name: Build jslib
|
2020-07-23 23:13:57 +02:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2021-10-13 16:18:02 +02:00
|
|
|
os: [windows-2019, macos-10.15, ubuntu-20.04]
|
2020-07-23 23:02:59 +02:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Set up Node
|
2021-05-17 18:46:54 +02:00
|
|
|
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
|
2020-07-23 23:02:59 +02:00
|
|
|
with:
|
2021-12-13 11:43:10 +01:00
|
|
|
node-version: "16"
|
2020-07-23 23:02:59 +02:00
|
|
|
|
2021-12-13 11:43:10 +01:00
|
|
|
- name: Install node-gyp
|
2021-05-26 21:45:23 +02:00
|
|
|
run: |
|
|
|
|
npm install -g node-gyp
|
|
|
|
node-gyp install $(node -v)
|
|
|
|
|
2020-07-23 23:02:59 +02:00
|
|
|
- name: Print environment
|
|
|
|
run: |
|
|
|
|
node --version
|
|
|
|
npm --version
|
|
|
|
|
|
|
|
- name: Checkout repo
|
2021-05-17 18:46:54 +02:00
|
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
2020-07-23 23:02:59 +02:00
|
|
|
|
|
|
|
- name: Install Node dependencies
|
|
|
|
run: npm install
|
|
|
|
|
2021-12-16 12:45:01 +01:00
|
|
|
- name: Run linter
|
|
|
|
run: npm run lint
|
2020-07-23 23:02:59 +02:00
|
|
|
|
|
|
|
- name: Run tests
|
2020-07-24 15:49:59 +02:00
|
|
|
if: runner.os != 'Linux'
|
2020-07-23 23:02:59 +02:00
|
|
|
run: npm run test
|
|
|
|
|
2020-07-23 23:13:57 +02:00
|
|
|
- name: Upload test coverage artifact
|
2020-07-24 15:49:59 +02:00
|
|
|
if: runner.os != 'Linux'
|
2021-05-17 18:46:54 +02:00
|
|
|
uses: actions/upload-artifact@ee69f02b3dfdecd58bb31b4d133da38ba6fe3700
|
2020-07-23 23:02:59 +02:00
|
|
|
with:
|
|
|
|
name: test-coverage
|
|
|
|
path: coverage/
|
2021-10-14 20:34:17 +02:00
|
|
|
|
|
|
|
check-failures:
|
|
|
|
name: Check for failures
|
|
|
|
if: always()
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
needs:
|
|
|
|
- cloc
|
|
|
|
- build
|
|
|
|
steps:
|
|
|
|
- name: Check if any job failed
|
2021-10-15 19:06:46 +02:00
|
|
|
if: ${{ (github.ref == 'refs/heads/master') || (github.ref == 'refs/heads/rc') }}
|
2021-10-14 20:34:17 +02:00
|
|
|
env:
|
|
|
|
CLOC_STATUS: ${{ needs.cloc.result }}
|
|
|
|
BUILD_STATUS: ${{ needs.build.result }}
|
|
|
|
run: |
|
|
|
|
if [ "$CLOC_STATUS" = "failure" ]; then
|
|
|
|
exit 1
|
|
|
|
elif [ "$BUILD_STATUS" = "failure" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Login to Azure - Prod Subscription
|
|
|
|
uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a
|
|
|
|
if: failure()
|
|
|
|
with:
|
|
|
|
creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
|
|
|
|
|
|
|
|
- name: Retrieve secrets
|
|
|
|
id: retrieve-secrets
|
|
|
|
uses: Azure/get-keyvault-secrets@80ccd3fafe5662407cc2e55f202ee34bfff8c403
|
|
|
|
if: failure()
|
|
|
|
with:
|
|
|
|
keyvault: "bitwarden-prod-kv"
|
|
|
|
secrets: "devops-alerts-slack-webhook-url"
|
|
|
|
|
|
|
|
- name: Notify Slack on failure
|
|
|
|
uses: act10ns/slack@e4e71685b9b239384b0f676a63c32367f59c2522 # v1.2.2
|
|
|
|
if: failure()
|
|
|
|
env:
|
|
|
|
SLACK_WEBHOOK_URL: ${{ steps.retrieve-secrets.outputs.devops-alerts-slack-webhook-url }}
|
|
|
|
with:
|
|
|
|
status: ${{ job.status }}
|