bitwarden-estensione-browser/.github/workflows/build.yml

217 lines
6.2 KiB
YAML
Raw Normal View History

---
2021-02-02 00:27:08 +01:00
name: Build
on:
push:
branches-ignore:
- 'l10n_master'
workflow_dispatch:
inputs: {}
2021-02-02 00:27:08 +01:00
jobs:
cloc:
name: CLOC
runs-on: ubuntu-20.04
2021-02-02 00:27:08 +01:00
steps:
- name: Checkout repo
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
2021-02-02 00:27:08 +01:00
- name: Set up cloc
run: |
sudo apt update
sudo apt -y install cloc
- name: Print lines of code
run: cloc --include-lang TypeScript,JavaScript,HTML,Sass,CSS --vcs git
setup:
name: Setup
runs-on: ubuntu-20.04
2021-02-02 00:27:08 +01:00
outputs:
repo_url: ${{ steps.gen_vars.outputs.repo_url }}
adj_build_number: ${{ steps.gen_vars.outputs.adj_build_number }}
steps:
- name: Checkout repo
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
2021-02-02 00:27:08 +01:00
- name: Get Package Version
id: gen_vars
run: |
2021-02-02 23:27:29 +01:00
repo_url=https://github.com/$GITHUB_REPOSITORY.git
adj_build_num=${GITHUB_SHA:0:7}
2021-02-02 00:27:08 +01:00
echo "::set-output name=repo_url::$repo_url"
echo "::set-output name=adj_build_number::$adj_build_num"
2021-02-02 00:27:08 +01:00
locales-test:
name: Locales Test
runs-on: ubuntu-20.04
2021-02-02 00:27:08 +01:00
needs: setup
steps:
- name: Checkout repo
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
2021-02-02 00:27:08 +01:00
2021-05-13 22:28:36 +02:00
- name: Testing locales - extName length
2021-05-13 00:25:13 +02:00
run: |
2021-05-13 22:43:19 +02:00
found_error=false
echo "Locales Test"
echo "============"
echo "extName string must be 40 characters or less"
echo
for locale in $(ls src/_locales/); do
string_length=$(jq '.extName.message | length' src/_locales/$locale/messages.json)
if [[ $string_length -gt 40 ]]; then
echo "$locale: $string_length"
found_error=true
fi
done
2021-05-13 22:43:19 +02:00
if $found_error; then
echo
echo "Please fix 'extName' for the locales listed above."
exit 1
else
echo "Test passed!"
fi
2021-05-13 00:27:47 +02:00
build:
name: Build
runs-on: windows-2019
needs:
- setup
- locales-test
env:
_BUILD_NUMBER: ${{ needs.setup.outputs.adj_build_number }}
steps:
- name: Checkout repo
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
- name: Set up Node
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
with:
node-version: '14'
2021-05-26 22:34:31 +02:00
- name: Update NPM
run: |
npm install -g npm@7
- name: Print environment
run: |
node --version
npm --version
- name: NPM setup & test
2021-02-02 00:27:08 +01:00
run: |
npm install
npm run dist
npm run test
- name: Gulp
2021-02-02 00:27:08 +01:00
run: gulp ci
- name: Build sources for reviewers
shell: cmd
run: |
mkdir dist\Source
call git clone %_REPO_URL% dist\Source
cd dist\Source
call git checkout %GITHUB_SHA%
call git submodule update --init --recursive
cd ../
del /S/Q "Source\.git\objects\pack\*"
call 7z a browser-source-%_BUILD_NUMBER%.zip "Source\*"
- name: Upload Opera artifact
uses: actions/upload-artifact@ee69f02b3dfdecd58bb31b4d133da38ba6fe3700
2021-02-02 00:27:08 +01:00
with:
name: dist-opera-${{ env._BUILD_NUMBER }}.zip
2021-09-14 21:46:25 +02:00
path: dist/dist-opera.zip
2021-09-14 21:03:36 +02:00
if-no-files-found: error
2021-02-02 00:27:08 +01:00
- name: Upload Chrome artifact
uses: actions/upload-artifact@ee69f02b3dfdecd58bb31b4d133da38ba6fe3700
2021-02-02 00:27:08 +01:00
with:
name: dist-chrome-${{ env._BUILD_NUMBER }}.zip
2021-09-14 21:46:25 +02:00
path: dist/dist-chrome.zip
2021-09-14 21:03:36 +02:00
if-no-files-found: error
2021-02-02 00:27:08 +01:00
- name: Upload Firefox artifact
uses: actions/upload-artifact@ee69f02b3dfdecd58bb31b4d133da38ba6fe3700
2021-02-02 00:27:08 +01:00
with:
name: dist-firefox-${{ env._BUILD_NUMBER }}.zip
2021-09-14 21:46:25 +02:00
path: dist/dist-firefox.zip
2021-09-14 21:03:36 +02:00
if-no-files-found: error
2021-02-02 00:27:08 +01:00
- name: Upload Edge artifact
uses: actions/upload-artifact@ee69f02b3dfdecd58bb31b4d133da38ba6fe3700
2021-02-02 00:27:08 +01:00
with:
name: dist-edge-${{ env._BUILD_NUMBER }}.zip
2021-09-14 21:46:25 +02:00
path: dist/dist-edge.zip
2021-09-14 21:03:36 +02:00
if-no-files-found: error
2021-02-02 00:27:08 +01:00
- name: Upload browser source
uses: actions/upload-artifact@ee69f02b3dfdecd58bb31b4d133da38ba6fe3700
with:
name: browser-source-${{ env._BUILD_NUMBER }}.zip
path: dist/browser-source-${{ env._BUILD_NUMBER }}.zip
if-no-files-found: error
2021-02-02 22:27:15 +01:00
- name: Upload coverage artifact
if: false
uses: actions/upload-artifact@ee69f02b3dfdecd58bb31b4d133da38ba6fe3700
2021-02-02 00:27:08 +01:00
with:
name: coverage-${{ env._BUILD_NUMBER }}.zip
path: coverage/coverage-${{ env._BUILD_NUMBER }}.zip
2021-09-14 21:03:36 +02:00
if-no-files-found: error
2021-10-13 23:54:22 +02:00
check-failures:
name: Check for failures
if: always()
runs-on: ubuntu-20.04
needs:
- cloc
- setup
- locales-test
- build
steps:
- name: Check if any job failed
env:
CLOC_STATUS: ${{ needs.cloc.result }}
SETUP_STATUS: ${{ needs.setup.result }}
LOCALES_TEST_STATUS: ${{ needs.locales-test.result }}
BUILD_STATUS: ${{ needs.build.result }}
run: |
if [ "$CLOC_STATUS" = "failure" ]; then
exit 1
elif [ "$SETUP_STATUS" = "failure" ]; then
exit 1
elif [ "$LOCALES_TEST_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 }}