Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 186 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
version: 2.1
orbs:
queue: eddiewebb/queue@1.0.110

_defaults: &defaults
working_directory: ~/repo
_docker_defaults: &docker_defaults
image: circleci/node:14
_steps:
queue_until_front_of_line: &queue_until_front_of_line
# Ensures we don't deploy concurrently
# See https://github.com/eddiewebb/circleci-queue
queue/until_front_of_line:
time: "60"
consider-job: true
consider-branch: true
dont-quit: false
restore_npm_cache: &restore_npm_cache
restore_cache:
keys:
- npm-v1-{{ .Branch }}-{{ checksum "package-lock.json" }}
- npm-v1-{{ .Branch }}-
- npm-v1-
save_npm_cache: &save_npm_cache
save_cache:
paths:
- .npm-cache
key: npm-v1-{{ .Branch }}-{{ checksum "package-lock.json" }}
install_pip: &install_pip
run: sudo apt-get update && sudo apt-get install python-pip
install_aws_cli: &install_aws_cli
run: sudo pip install awscli
install_dependencies: &install_dependencies
run: npm ci --cache .npm-cache && sudo npm i -g --registry https://npm.pkg.github.com/microbit-foundation @microbit-foundation/website-deploy-aws@0.1.0 @microbit-foundation/website-deploy-aws-config@0.2.0 @microbit-foundation/circleci-npm-package-versioner@1

update_version: &update_version
run: npm run ci:update-version
build: &build
run:
name: Build
command: npm run ci
# https://circleci.com/orbs/registry/orb/threetreeslight/puppeteer
chrome-deps: &chrome-deps
run:
name: Install Headless Chrome dependencies
command: |
sudo apt-get install -yq \
gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \
libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 \
libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates \
fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
serve: &serve
run:
name: Serve files for e2e tests
command: npm run serve
background: true
serve-wait: &serve-wait
run:
name: Wait for e2e server
command: "curl --insecure -4 --retry 7 --retry-connrefused http://localhost:3000 1>/dev/null"
e2e: &e2e
run:
name: e2e tests
command: npm run test:e2e:headless
store_reports: &store_reports
store_artifacts:
path: reports/
destination: reports
deploy: &deploy
run:
name: Deploy
environment:
NODE_PATH: /usr/local/lib/node_modules
command: npm run deploy
invalidate: &invalidate
run:
name: Invalidate CloudFront distribution
command: "[ $STAGE = 'REVIEW' ] && echo Skipping || npm run invalidate"
tidy_review_buckets: &tidy_review_buckets
run:
name: Tidy review buckets
command: "[ $STAGE = 'REVIEW' ] && echo Skipping || npm run tidy-review-buckets"
configure_registry_auth: &configure_registry_auth
run:
name: Configure registry auth
# This is only needed for the deployment tools that we install globally.
command: sudo echo "//npm.pkg.github.com/:_authToken=$GITHUB_TOKEN" | sudo tee -a /root/.npmrc > /dev/null

jobs:
review:
<<: *defaults
docker:
- <<: *docker_defaults
environment:
STAGE: REVIEW
REACT_APP_STAGE: REVIEW
steps:
- checkout
- *restore_npm_cache
- *configure_registry_auth
- *install_pip
- *install_aws_cli
- *install_dependencies
- *update_version
- *save_npm_cache
- *build
- *chrome-deps
- *serve
- *serve-wait
- *e2e
- *store_reports
- *queue_until_front_of_line
- *deploy
staging:
<<: *defaults
docker:
- <<: *docker_defaults
environment:
STAGE: STAGING
REACT_APP_STAGE: STAGING
steps:
- checkout
- *restore_npm_cache
- *configure_registry_auth
- *install_pip
- *install_aws_cli
- *install_dependencies
- *update_version
- *save_npm_cache
- *build
- *queue_until_front_of_line
- *chrome-deps
- *serve
- *serve-wait
- *e2e
- *store_reports
- *deploy
- *invalidate
- *tidy_review_buckets

production:
<<: *defaults
docker:
- <<: *docker_defaults
environment:
STAGE: PRODUCTION
REACT_APP_STAGE: PRODUCTION
steps:
- checkout
- *restore_npm_cache
- *configure_registry_auth
- *install_pip
- *install_aws_cli
- *install_dependencies
- *update_version
- *save_npm_cache
- *build
# This doesn't work for tags. Don't release more than one at once!
# - *queue_until_front_of_line
- *deploy
- *invalidate
- *tidy_review_buckets

workflows:
version: 2
review:
jobs:
- review:
filters:
branches:
ignore: main
staging:
jobs:
- staging:
filters:
branches:
only: main
production:
jobs:
- production:
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
12 changes: 12 additions & 0 deletions .github/workflows/pr-url.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "pr-url"
on:
pull_request:
types: [opened]
jobs:
pr-url:
runs-on: ubuntu-latest
steps:
- uses: microbit-foundation/action-pr-url-template@v0.1.2
with:
uri-template: "http://{branch}.review.python-editor-next.microbit.org.s3-website-eu-west-1.amazonaws.com"
repo-token: ${{ secrets.GITHUB_TOKEN }}
16 changes: 16 additions & 0 deletions deployment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const createDeploymentDetails = require("@microbit-foundation/website-deploy-aws-config");

const { s3Config } = createDeploymentDetails();
module.exports = {
...s3Config,
region: "eu-west-1",
removeNonexistentObjects: true,
enableS3StaticWebsiteHosting: true,
errorDocumentKey: "index.html",
redirects: [],
params: {
"static/**": { CacheControl: "public, max-age=31536000, immutable" },
"**/**/!(sw).js": { CacheControl: "public, max-age=31536000, immutable" },
"**/**.css": { CacheControl: "public, max-age=31536000, immutable" },
},
};
Loading