Skip to content

Commit

Permalink
merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
karanbirsingh committed Aug 10, 2021
2 parents fb212c0 + 0b9142b commit 12fe2f9
Show file tree
Hide file tree
Showing 18 changed files with 1,317 additions and 79,601 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,20 @@ jobs:
checks: write
pull-requests: write
steps:
- uses: actions/checkout@v2
- name: Checkout repo
uses: actions/checkout@v2

- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 12.x

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build
run: yarn cbuild

- name: Scan test site
uses: ./packages/gh-action/
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

**/node_modules
node_modules/
dist/
drop/
test-results/
out/
Expand Down
33 changes: 13 additions & 20 deletions dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,28 @@ Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License.
-->

# Project structure

This repository contains code for two projects:

- `packages/gh-action` contains a GitHub action, also released to tags in this repository
- `packages/ado-extension` is an in-progress Azure DevOps extension
- `packages/shared` contains most of the shared logic from the two projects; over time, product-specific code should move from `packages/shared` into the appropriate product folder

We use `lerna` and `yarn workspaces` to manage the monorepo. In most cases, running yarn scripts in the root directory should produce output from all packages.

# Development workflow

To make a change, you can follow these steps:

- clone the repository. While our team typically uses forks, the action (and therefore our self-test workflow) doesn't support pull requests from forks yet (tracked [here](https://github.com/microsoft/accessibility-insights-action/issues/629)). For this reason, maintainers might consider working off branches of the main repository. To test a fork, you can consume your fork's branch from a different repository.
- run `yarn install`. You might encounter `Found incompatible module` because one of our dependencies expects node versions `^10.17.0 || ^12.3.0`. You can use `yarn install --ignore-engines` to ignore this error.
- make your code change
- run `yarn build` and/or `yarn test`
- run `yarn build` and/or `yarn test`. If you're changing `shared`, you may need to build it before `gh-action` picks up changes.
- test your changes either
- locally: follow the instructions below this section
- remotely: push your post-build changes to GitHub and consume your branch from a separate repository. Replace `uses: microsoft/accessibility-insights-action@v2` with `uses: YourAccount/accessibility-insights-action@YourBranchOrSHA`
- push your post-build changes to GitHub (notably, your diff will likely include `dist/index.js`)
- remotely: push your changes to GitHub and consume your branch from a separate repository. Replace `uses: microsoft/accessibility-insights-action@v2` with `uses: YourAccount/accessibility-insights-action@YourBranchOrSHA`
- push your changes to GitHub
- create a pull request. If your branch is on the main repo, the PR build should run your implementation against the test files in `website-root`.

# Run GitHub Actions locally
Expand Down Expand Up @@ -84,20 +94,3 @@ _Note_: When run act first time choose **large** image option.
_Note_: When you get an error about composite actions is not supported then [build act from source](https://github.com/nektos/act#building-from-source) to use latest features.

Action is running inside a docker container. After action is completed the docker container is still running to preserve chrome setup and reduce subsequent action startup time.

# Release instructions

To create a new release, a repo maintainer should follow these steps:

1. Create and merge a release pull request to `main` which:
- Updates `/package.json` with a new semantic version number
- Updates `/docs/usage.md` if needed to reference the upcoming tag
- Updates `/dist/` with the results of `yarn build`
- Updates `/NOTICES.txt` based on the dependencies in `yarn.lock`. If your release PR updates `yarn.lock`, you might consider splitting this step out into a separate follow-up PR.
2. Validate the release build
- Wait for a passing CI build against `main`
- Update a separate test repository to refer to `accessibility-insights-action@mergecommithash` and verify that it functions as expected
3. Create/update the corresponding git tags for the release:
- Create a new release tag using the version in `package.json` (eg, `git tag v1.2.3`)
- Update the corresponding major-version tag (eg, `git tag -f v1`)
- Push both tags
4 changes: 2 additions & 2 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Avoid referring to `@main` directly; it may contain undocumented breaking change

Reference this action in your GitHub workflow with the snippets on this page.

- See [action.yml](https://github.com/microsoft/accessibility-insights-action/blob/main/action.yml) for option descriptions.
- See [action.yml](https://github.com/microsoft/accessibility-insights-action/blob/v2/action.yml) for option descriptions. Make sure you view the correct source file for your version (e.g. v2 in the URL)
- See [GitHub's documentation](https://docs.github.com/en/actions/learn-github-actions/introduction-to-github-actions#create-an-example-workflow) for a primer on GitHub actions.

### Basic template
Expand Down Expand Up @@ -95,7 +95,7 @@ Generally `/` on Ubuntu and `//` on Windows are good defaults for `scan-url-rela

### Modify crawling options

The action supports several crawling options defined in [action.yml](https://github.com/microsoft/accessibility-insights-action/blob/main/action.yml).
The action supports several crawling options defined in [action.yml](https://github.com/microsoft/accessibility-insights-action/blob/v2/action.yml).

For instance, you can:

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
"@types/puppeteer-core": "^5.4.0",
"@types/serve-static": "^1.13.10",
"@types/verror": "^1.10.5",
"@typescript-eslint/eslint-plugin": "^4.29.0",
"@typescript-eslint/eslint-plugin": "^4.29.1",
"@typescript-eslint/parser": "^4.29.0",
"case-sensitive-paths-webpack-plugin": "^2.4.0",
"codecov": "^3.8.3",
"eslint": "^7.32.0",
"eslint-plugin-security": "^1.4.0",
"fork-ts-checker-webpack-plugin": "^6.3.1",
"fork-ts-checker-webpack-plugin": "^6.3.2",
"jest": "^27.0.6",
"jest-extended": "^0.11.5",
"jest-file-snapshot": "^0.5.0",
Expand All @@ -64,7 +64,7 @@
"ts-loader": "^9.2.5",
"typemoq": "^2.1.0",
"typescript": "^4.3.5",
"webpack": "^5.48.0",
"webpack": "^5.49.0",
"webpack-cli": "^4.7.2"
},
"resolutions": {
Expand Down
32 changes: 32 additions & 0 deletions packages/ado-extension/ado-extension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"manifestVersion": 1,
"id": "accessibility-insights-ado-extension",
"name": "Accessibility Insights Azure DevOps Extension",
"version": "1.0.1",
"publisher": "accessibility-insights-feature-crew",
"targets": [
{
"id": "Microsoft.VisualStudio.Services"
}
],
"description": "Scan accessibility issues in an Azure DevOps pipeline",
"categories": ["Azure Pipelines"],
"icons": {
"default": "pkg/extension-icon.png"
},
"files": [
{
"path": "pkg"
}
],
"contributions": [
{
"id": "accessibility-insights-ado-task",
"type": "ms.vss-distributed-task.task",
"targets": ["ms.vss-distributed-task.tasks"],
"properties": {
"name": "pkg"
}
}
]
}
9 changes: 9 additions & 0 deletions packages/ado-extension/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
const baseConfig = require('../../jest.config.base');
const package = require('./package');

module.exports = {
...baseConfig,
displayName: package.name,
};
35 changes: 35 additions & 0 deletions packages/ado-extension/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@accessibility-insights-action/ado-extension",
"private": true,
"version": "0.0.1",
"description": "This project welcomes contributions and suggestions. Most contributions require you to agree to a\r Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us\r the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.",
"main": "dist/pkg/index.js",
"scripts": {
"build": "tsc && node prepare-package-dir.js",
"cbuild": "npm-run-all --serial clean build",
"clean": "rimraf dist",
"lint:check": "eslint -c ../../.eslintrc.js \"src/**/*.{js,ts}\"",
"lint:fix": "eslint -c ../../.eslintrc.js \"src/**/*.{js,ts}\" --quiet --fix",
"package": "cd dist && tfx extension create --manifest-globs ado-extension.json",
"start": "node dist/pkg/index.js",
"test": "jest",
"watch:test": "jest --watch"
},
"repository": {
"type": "git",
"url": "git+https://github.com/microsoft/accessibility-insights-action.git"
},
"author": "Microsoft",
"license": "MIT",
"bugs": {
"url": "https://github.com/microsoft/accessibility-insights-action/issues"
},
"homepage": "https://github.com/microsoft/accessibility-insights-action#readme",
"devDependencies": {
"tfx-cli": "^0.9.2"
},
"dependencies": {
"reflect-metadata": "^0.1.13",
"@accessibility-insights-action/shared": "^1.0.0"
}
}
44 changes: 44 additions & 0 deletions packages/ado-extension/prepare-package-dir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// run from root folder, this scripts prepares the dist folder

const fs = require('fs-extra');

// We allow overrides of extension/task identifiers so we can deploy
// different versions of the extension with the same YAML
const taskJson = JSON.parse(fs.readFileSync('task.json'));
const extensionJson = JSON.parse(fs.readFileSync('ado-extension.json'));

const overrideExtensionName = process.env.ADO_EXTENSION_NAME;
if (overrideExtensionName && overrideExtensionName.length > 0) {
taskJson.name = overrideExtensionName;
taskJson.friendlyName = overrideExtensionName;
extensionJson.name = overrideExtensionName;
}

const overrideExtensionId = process.env.ADO_EXTENSION_ID;
if (overrideExtensionId && overrideExtensionId.length > 0) {
extensionJson.id = overrideExtensionId;
}

const overrideTaskId = process.env.ADO_TASK_ID;
if (overrideTaskId && overrideTaskId.length > 0) {
taskJson.id = overrideTaskId;
}

console.log(JSON.stringify(extensionJson, null, 4));
fs.writeJSONSync('dist/ado-extension.json', extensionJson);
console.log('copied ado-extension.json to dist/pkg/ado-extension.json with any overrides');

console.log(JSON.stringify(taskJson, null, 4));
fs.writeJSONSync('dist/pkg/task.json', taskJson);
console.log('copied task.json to dist/pkg/task.json with any overrides');

fs.copyFileSync('package.json', 'dist/pkg/package.json');
console.log('copied package.json to dist/pkg/package.json');

fs.copyFileSync('../../yarn.lock', 'dist/pkg/yarn.lock');
console.log('copied yarn.lock to dist/pkg/yarn.lock');

fs.copyFileSync('../../icons/brand-blue-48px.png', 'dist/pkg/extension-icon.png');
console.log('copied brand-blue-48px.png to dist/pkg/extension-icon.png');
8 changes: 8 additions & 0 deletions packages/ado-extension/src/ado-extension-test.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

describe('ADO Extension test infrastructure', () => {
it('placeholder test in ADO extension wrapper package', () => {
expect(0).toBe(0);
});
});
8 changes: 8 additions & 0 deletions packages/ado-extension/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
try {
console.log('Hello World');
} catch (error) {
console.log('Exception thrown in action: ', error);
process.exit(1);
}
37 changes: 37 additions & 0 deletions packages/ado-extension/task.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "https://raw.githubusercontent.com/Microsoft/azure-pipelines-task-lib/master/tasks.schema.json",
"id": "9fbe8277-f1b8-4d71-9045-5e6d815b46d8",
"name": "AI task for ADO",
"friendlyName": "AI task",
"description": "Accessbility Insights Task for ADO pipeline",
"helpMarkDown": "",
"category": "Utility",
"author": "Accessibility Insights",
"version": {
"Major": 1,
"Minor": 1,
"Patch": 1
},
"instanceNameFormat": "Run accessibility testing",
"inputs": [
{
"name": "url",
"type": "string",
"label": "website URL",
"required": false,
"helpMarkDown": "URL to scan"
},
{
"name": "repoServiceConnectionName",
"type": "connectedService:externaltfs",
"label": "Azure Repos Connection",
"required": false,
"helpMarkDown": "This extension makes comments on pull requests. Provide a service connection with permissions to contribute to the target repo."
}
],
"execution": {
"Node10": {
"target": "index.js"
}
}
}
8 changes: 8 additions & 0 deletions packages/ado-extension/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist/pkg/"
}
}
Loading

0 comments on commit 12fe2f9

Please sign in to comment.