Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from CircleCI to GitHub actions #1087

Merged
merged 1 commit into from
Jan 17, 2023
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
204 changes: 0 additions & 204 deletions .circleci/config.yml

This file was deleted.

64 changes: 64 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: build

on:
release:
types: [created]
push:
branches:
- "**"

# This is conservative: ideally we'd include branch and stage in this key
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
concurrency: deploy-python-editor-v3

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
env:
AWS_DEFAULT_REGION: eu-west-1
PRODUCTION_CLOUDFRONT_DISTRIBUTION_ID: E2ELTBTA2OFPY2
STAGING_CLOUDFRONT_DISTRIBUTION_ID: E2ELTBTA2OFPY2
REVIEW_CLOUDFRONT_DISTRIBUTION_ID: E3267W09ZJHQG9

steps:
# Note: This workflow will not run on forks without modification; we're open to making steps
# that reply on our deployment infrastructure conditional. Please open an issue.
- uses: actions/checkout@v3
- name: Configure node
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: "npm"
registry-url: "https://npm.pkg.github.com"
- run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: npm install --no-save @microbit-foundation/[email protected] @microbit-foundation/[email protected] @microbit-foundation/[email protected] @microbit-foundation/circleci-npm-package-versioner@1
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: node ./bin/print-ci-env.js >> $GITHUB_ENV
- run: npm run ci:update-version
- run: npm run ci
- run: mkdir -p /tmp/app${PUBLIC_URL} && cp -r build/* /tmp/app${PUBLIC_URL} && npx serve --no-clipboard -l 3000 /tmp/app &
if: env.STAGE == 'REVIEW' || env.STAGE == 'STAGING'
- run: curl --insecure -4 --retry 7 --retry-connrefused http://localhost:3000 1>/dev/null
if: env.STAGE == 'REVIEW' || env.STAGE == 'STAGING'
- run: npm run test:e2e:headless
if: env.STAGE == 'REVIEW' || env.STAGE == 'STAGING'
- name: Store reports
if: env.STAGE == 'REVIEW' || env.STAGE == 'STAGING'
uses: actions/upload-artifact@v3
with:
name: reports
path: reports/
- run: npm run deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.WEB_DEPLOY_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.WEB_DEPLOY_AWS_SECRET_ACCESS_KEY }}
- run: npm run invalidate
env:
AWS_ACCESS_KEY_ID: ${{ secrets.WEB_DEPLOY_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.WEB_DEPLOY_AWS_SECRET_ACCESS_KEY }}
21 changes: 21 additions & 0 deletions bin/print-ci-env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env node
const { bucketPrefix } = require("../deployment");
const ref = process.env.GITHUB_REF;
const eventName = process.env.GITHUB_EVENT_NAME;

let stage = "";
if (ref === "refs/heads/main") {
if (eventName === "release") {
stage = "PRODUCTION";
} else {
stage = "STAGING";
}
} else {
stage = "REVIEW";
}

console.log(`STAGE=${stage}`);
console.log(`REACT_APP_STAGE=${stage}`);
// Two env vars as PUBLIC_URL seems to be blank when running jest even if we set it.
console.log(`PUBLIC_URL=/${bucketPrefix}/`);
console.log(`E2E_PUBLIC_URL=/${bucketPrefix}/`);
10 changes: 0 additions & 10 deletions bin/public-url.js

This file was deleted.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@
"invalidate": "aws cloudfront create-invalidation --distribution-id $(printenv ${STAGE}_CLOUDFRONT_DISTRIBUTION_ID) --paths \"/*\"",
"i18n:compile": "node bin/tidy-lang.js && formatjs compile-folder --ast lang src/messages",
"i18n:convert": "node bin/tidy-lang.js && node bin/crowdin-convert.js",
"fix-licensing-headers": "node bin/fix-licensing-headers.js",
"public-url": "node bin/public-url.js"
"fix-licensing-headers": "node bin/fix-licensing-headers.js"
},
"eslintConfig": {
"extends": [
Expand Down
14 changes: 12 additions & 2 deletions src/e2e/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class App {
await dialog.accept();
});

const logsPath = reportsPath + expect.getState().currentTestName + ".txt";
const logsPath = this.reportFilename("txt");
// Clears previous output from local file.
fs.writeFile(logsPath, "", (err) => {
if (err) {
Expand Down Expand Up @@ -1052,10 +1052,20 @@ export class App {
async screenshot() {
const page = await this.page;
return page.screenshot({
path: reportsPath + expect.getState().currentTestName + ".png",
path: this.reportFilename("png"),
});
}

private reportFilename(extension: string): string {
return (
reportsPath +
// GH actions has character restrictions
expect.getState().currentTestName.replace(/[^0-9a-zA-Z]+/g, "-") +
"." +
extension
);
}

private async focusEditorContent(): Promise<ElementHandle> {
const document = await this.document();
const content = await document.$("[data-testid='editor'] .cm-content");
Expand Down