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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

268 lines
7.9 KiB
YAML
Raw Normal View History

---
name: Build Browser
2021-02-02 00:27:08 +01:00
on:
push:
branches-ignore:
- 'l10n_master'
- 'gh-pages'
paths:
- 'apps/browser/**'
2021-02-02 00:27:08 +01:00
workflow_dispatch:
inputs: {}
2021-02-02 00:27:08 +01:00
defaults:
run:
shell: bash
working-directory: apps/browser
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@a12a3943b4bdde767164f792f33f40b04645d846 # v3.0.0
2021-02-02 00:27:08 +01:00
- name: Set up cloc
run: |
sudo apt update
sudo apt -y install cloc
2021-02-02 00:27:08 +01:00
- name: Print lines of code
run: cloc --include-lang TypeScript,JavaScript,HTML,Sass,CSS --vcs git
2022-03-15 22:08:43 +01:00
2021-02-02 00:27:08 +01:00
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@a12a3943b4bdde767164f792f33f40b04645d846 # v3.0.0
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
2022-03-15 22:08:43 +01:00
locales-test:
name: Locales Test
runs-on: ubuntu-20.04
needs:
2022-01-28 19:29:49 +01:00
- setup
2021-02-02 00:27:08 +01:00
steps:
- name: Checkout repo
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # v3.0.0
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
2022-03-15 22:08:43 +01: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@a12a3943b4bdde767164f792f33f40b04645d846 # v3.0.0
- name: Set up Node
2022-03-15 22:08:43 +01:00
uses: actions/setup-node@9ced9a43a244f3ac94f13bfd896db8c8f30da67a # v3.0.0
with:
2022-03-15 22:08:43 +01:00
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
node-version: '16'
- name: Print environment
run: |
node --version
npm --version
- name: NPM setup & test
2021-02-02 00:27:08 +01:00
run: |
2021-12-03 21:35:34 +01:00
npm ci
2021-02-02 00:27:08 +01:00
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 %GITHUB_SERVER_URL%/%GITHUB_REPOSITORY% 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.zip "Source\*"
- name: Upload Opera artifact
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v3.0.0
2021-02-02 00:27:08 +01:00
with:
name: dist-opera-${{ env._BUILD_NUMBER }}.zip
path: apps/browser/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@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v3.0.0
2021-02-02 00:27:08 +01:00
with:
name: dist-chrome-${{ env._BUILD_NUMBER }}.zip
path: apps/browser/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@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v3.0.0
2021-02-02 00:27:08 +01:00
with:
name: dist-firefox-${{ env._BUILD_NUMBER }}.zip
path: apps/browser/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@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v3.0.0
2021-02-02 00:27:08 +01:00
with:
name: dist-edge-${{ env._BUILD_NUMBER }}.zip
path: apps/browser/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@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v3.0.0
with:
name: browser-source-${{ env._BUILD_NUMBER }}.zip
path: apps/browser/dist/browser-source.zip
if-no-files-found: error
2021-02-02 22:27:15 +01:00
- name: Upload coverage artifact
if: false
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v3.0.0
2021-02-02 00:27:08 +01:00
with:
name: coverage-${{ env._BUILD_NUMBER }}.zip
path: apps/browser/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
2021-11-04 21:02:06 +01:00
crowdin-push:
name: Crowdin Push
2021-11-04 21:04:59 +01:00
if: github.ref == 'refs/heads/master'
2021-11-04 21:02:06 +01:00
runs-on: ubuntu-20.04
needs:
- build
env:
_CROWDIN_PROJECT_ID: "268134"
steps:
- name: Checkout repo
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # v3.0.0
2021-11-04 21:02:06 +01:00
- name: Login to Azure
uses: Azure/login@1f63701bf3e6892515f1b7ce2d2bf1708b46beaf
2021-11-04 21:02:06 +01:00
with:
creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
- name: Retrieve secrets
id: retrieve-secrets
2022-03-15 20:43:45 +01:00
uses: Azure/get-keyvault-secrets@b5c723b9ac7870c022b8c35befe620b7009b336f
2021-11-04 21:02:06 +01:00
with:
keyvault: "bitwarden-prod-kv"
secrets: "crowdin-api-token"
- name: Upload Sources
uses: crowdin/github-action@9237b4cb361788dfce63feb2e2f15c09e2fe7415 # v1.4.7
2021-11-04 21:02:06 +01:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_API_TOKEN: ${{ steps.retrieve-secrets.outputs.crowdin-api-token }}
with:
config: apps/browser/crowdin.yml
2021-11-04 21:02:06 +01:00
crowdin_branch_name: master
upload_sources: true
upload_translations: false
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
2021-11-04 21:02:06 +01:00
- crowdin-push
2021-10-13 23:54:22 +02:00
steps:
- name: Check if any job failed
2021-10-15 19:07:15 +02:00
if: ${{ (github.ref == 'refs/heads/master') || (github.ref == 'refs/heads/rc') }}
2021-10-13 23:54:22 +02:00
env:
CLOC_STATUS: ${{ needs.cloc.result }}
SETUP_STATUS: ${{ needs.setup.result }}
LOCALES_TEST_STATUS: ${{ needs.locales-test.result }}
BUILD_STATUS: ${{ needs.build.result }}
2021-11-04 21:02:06 +01:00
CROWDIN_PUSH_STATUS: ${{ needs.crowdin-push.result }}
2021-10-13 23:54:22 +02:00
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
2021-11-04 21:02:06 +01:00
elif [ "$CROWDIN_PUSH_STATUS" = "failure" ]; then
exit 1
2021-10-13 23:54:22 +02:00
fi
2021-11-04 21:02:06 +01:00
2021-10-13 23:54:22 +02:00
- name: Login to Azure - Prod Subscription
uses: Azure/login@1f63701bf3e6892515f1b7ce2d2bf1708b46beaf
2021-10-13 23:54:22 +02:00
if: failure()
with:
creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
- name: Retrieve secrets
id: retrieve-secrets
2022-03-15 20:43:45 +01:00
uses: Azure/get-keyvault-secrets@b5c723b9ac7870c022b8c35befe620b7009b336f
2021-10-13 23:54:22 +02:00
if: failure()
with:
keyvault: "bitwarden-prod-kv"
secrets: "devops-alerts-slack-webhook-url"
- name: Notify Slack on failure
uses: act10ns/slack@da3191ebe2e67f49b46880b4633f5591a96d1d33 # v1.5.0
2021-10-13 23:54:22 +02:00
if: failure()
env:
SLACK_WEBHOOK_URL: ${{ steps.retrieve-secrets.outputs.devops-alerts-slack-webhook-url }}
with:
status: ${{ job.status }}