Skip to content

Commit

Permalink
Merge pull request #23 from motin/deterministic-builds
Browse files Browse the repository at this point in the history
Deterministic builds + instructions on how to reproduce CI builds locally
  • Loading branch information
jmccrosky authored Jul 10, 2021
2 parents 8af15dc + b126f96 commit 6ce8aa2
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 15 deletions.
15 changes: 9 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ jobs:
docker:
- image: circleci/node:latest-browsers

environment:
# CircleCI builds production builds and thus uses production environment variables
SENTRY_DSN: https://fbd070810c8c47f1bf9a1a17e8909d4d@sentry.prod.mozaws.net/524
TELEMETRY_SERVER: https://incoming.telemetry.mozilla.org

working_directory: ~/checkout

steps:
Expand All @@ -19,9 +14,17 @@ jobs:
name: Install dependencies
command: yarn install --frozen-lockfile

- run:
name: Use CI non-sensitive env vars
command: cp .env.ci .env.production

- run:
name: Use CI non-sensitive env vars for testing
command: cp .env.ci .env.development

- run:
name: Output the current Sentry configuration
command: npx sentry-cli info
command: npx sentry-cli info || true

- run:
name: Build extension - Firefox
Expand Down
3 changes: 3 additions & 0 deletions .env.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Used in the client
SENTRY_DSN=https://fbd070810c8c47f1bf9a1a17e8909d4d@sentry.prod.mozaws.net/524
TELEMETRY_SERVER=https://incoming.telemetry.mozilla.org
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ yarn-error.log
node_modules/
.env*
!.env.example
!.env.ci
27 changes: 27 additions & 0 deletions docs/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- [Create release builds](#create-release-builds)
- [Upload and get approval of the artifacts](#upload-and-get-approval-of-the-artifacts)
- [AMO (addons.mozilla.org)](#amo-addonsmozillaorg)
- [Reproducing the Firefox CI build locally for add-on verification](#reproducing-the-firefox-ci-build-locally-for-add-on-verification)
- [CWS - Chrome Web Store](#cws---chrome-web-store)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->
Expand Down Expand Up @@ -65,6 +66,32 @@ Artifacts built locally or via CircleCI are unsigned, and are installed as per f
- AMO reviewers may want to see the release PR and/or a GitHub diff between the previously published version and the new release
- The new release will be live once AMO review is ready and approved

#### Reproducing the Firefox CI build locally for add-on verification

Due to the fact that webpack sometimes uses local paths in the builds and that build results may differ slightly
depending on which system it is built upon, we recommend using Docker to minimize the differences
between the builds built by CI and those built locally for add-on build process verification.

1. Start a Docker shell locally:

```
docker run -it -v "$(PWD)":/pwd circleci/node:latest-browsers /bin/bash
```

2. Run the following commands inside the container:

```
git clone https://github.com/mozilla-extensions/regrets-reporter.git /home/circleci/checkout
cd /home/circleci/checkout
yarn install --frozen-lockfile
cp .env.ci .env.production
yarn build:production
mkdir -p /pwd/docker-dist/firefox/
cp dist/firefox/* /pwd/docker-dist/firefox/
```

The reproduced build is now available in `docker-dist/firefox/` relative to the directory where the Docker shell was started.

### CWS - Chrome Web Store

- Log in to the CWS [Developer Dashboard](https://chrome.google.com/webstore/developer/dashboard)
Expand Down
18 changes: 9 additions & 9 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ if (!process.env.TELEMETRY_SERVER) {

// Only upload sources to Sentry if env vars are available, we are building a
// production build or we are testing the sentry plugin
if (
const uploadSourceToSentry =
process.env.SENTRY_AUTH_TOKEN &&
process.env.SENTRY_AUTH_TOKEN !== "foo" &&
(process.env.NODE_ENV === "production" ||
process.env.TEST_SENTRY_WEBPACK_PLUGIN === "1")
) {
plugins.push(
new SentryWebpackPlugin({
include: destPath,
}),
);
}
process.env.TEST_SENTRY_WEBPACK_PLUGIN === "1");

plugins.push(
new SentryWebpackPlugin({
include: destPath,
dryRun: !uploadSourceToSentry,
}),
);

module.exports = {
entry: {
Expand Down

0 comments on commit 6ce8aa2

Please sign in to comment.