diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 80063ce2..513764d5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,22 +1,114 @@ -# Build workflow -name: Build +# Build & lint checks workflow +name: Build & Lint Checks -on: [pull_request, workflow_dispatch] +on: + workflow_dispatch: + pull_request: + push: + branches: + - main permissions: contents: read jobs: + build_tip_of_tree_v12: + name: Build test (against tip-of-tree core v12) + runs-on: ubuntu-latest + steps: + - name: Checkout experimentation plugin + uses: actions/checkout@v4 + with: + path: main + + - name: Checkout core Blockly + uses: actions/checkout@v4 + with: + repository: 'google/blockly' + ref: 'rc/v12.0.0' + path: core-blockly + + - name: Use Node.js 20.x + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: NPM install + run: | + cd main + npm install + cd .. + cd core-blockly + npm install + cd .. + + - name: Link latest Blockly v12 + run: | + cd core-blockly + npm run package + cd dist + npm link + cd ../../main + npm link blockly + cd .. + + - name: Verify build + run: | + cd main + npm run build + build: + name: Build test (against pinned v12) + # Don't run pinned version checks for PRs. + if: ${{ !github.base_ref }} runs-on: ubuntu-latest steps: - - name: Checkout + - name: Checkout experimentation plugin uses: actions/checkout@v4 - - name: Setup Node + + - name: Use Node.js 20.x uses: actions/setup-node@v4 with: - node-version: latest - cache: 'npm' - - run: npm ci - - run: npm run build - - run: npm run lint + node-version: 20.x + + - name: NPM install + run: npm install + + - name: Verify build + run: npm run build + + lint: + name: Eslint check + timeout-minutes: 5 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js 20.x + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: NPM install + run: npm install + + - name: Eslint check format + run: npm run lint + + format: + name: Prettier check + timeout-minutes: 5 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js 20.x + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: NPM install + run: npm install + + - name: Prettier check format + run: npm run format:check diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..b3561226 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,93 @@ +# Workflow for running automated tests. + +name: Automated Tests + +on: + workflow_dispatch: + pull_request: + push: + branches: + - main + +permissions: + contents: read + +jobs: + webdriverio_tests_tip_of_tree_v12: + name: WebdriverIO tests (against tip-of-tree core v12) + timeout-minutes: 10 + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + + steps: + - name: Checkout experimentation plugin + uses: actions/checkout@v4 + with: + path: main + + - name: Checkout core Blockly + uses: actions/checkout@v4 + with: + repository: 'google/blockly' + ref: 'rc/v12.0.0' + path: core-blockly + + - name: Use Node.js 20.x + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: NPM install + run: | + cd main + npm install + cd .. + cd core-blockly + npm install + cd .. + + - name: Link latest Blockly v12 + run: | + cd core-blockly + npm run package + cd dist + npm link + cd ../../main + npm link blockly + cd .. + + - name: Run tests + run: | + cd main + npm run test + + webdriverio_tests: + name: WebdriverIO tests (against pinned v12) + # Don't run pinned version checks for PRs. + if: ${{ !github.base_ref }} + timeout-minutes: 10 + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + + steps: + - name: Checkout experimentation plugin + uses: actions/checkout@v4 + + - name: Use Node.js 20.x + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: NPM install + run: npm install + + - name: Run tests + run: npm run test diff --git a/package.json b/package.json index 9352f8a7..b8f6cbb1 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,9 @@ "ghpages": "webpack", "clean": "blockly-scripts clean", "lint": "eslint .", + "lint:fix": "eslint . --fix", "format": "prettier --write .", + "format:check": "prettier --check .", "predeploy": "blockly-scripts predeploy", "prepublishOnly": "npm login --registry https://wombat-dressing-room.appspot.com", "start": "blockly-scripts start",