Skip to content

Commit

Permalink
Merge pull request #1 from concord-consortium/186400442-basic-setup
Browse files Browse the repository at this point in the history
Export interface and helper functions. (PT-186400442)
  • Loading branch information
lublagg authored Nov 17, 2023
2 parents 5cebca8 + 38c841a commit aa5027b
Show file tree
Hide file tree
Showing 29 changed files with 540 additions and 558 deletions.
5 changes: 3 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module.exports = {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-shadow": ["error", { builtinGlobals: false, hoist: "all", allow: [] }],
"@typescript-eslint/no-this-alias": "warn",
"@typescript-eslint/no-unused-vars": ["warn", { args: "none", ignoreRestSiblings: true }],
"@typescript-eslint/prefer-optional-chain": "warn",
"@typescript-eslint/semi": ["warn", "always"],
Expand Down Expand Up @@ -73,10 +74,10 @@ module.exports = {
"no-var": "error",
"no-whitespace-before-property": "error",
"object-shorthand": "error",
"prefer-const": ["error", { destructuring: "all" }],
"prefer-const": ["warn", { destructuring: "all" }],
"prefer-object-spread": "error",
"prefer-regex-literals": "error",
"prefer-rest-params": "error",
"prefer-rest-params": "warn",
"prefer-spread": "error",
"quotes": ["error", "double", { allowTemplateLiterals: true, avoidEscape: true }],
"radix": "error",
Expand Down
57 changes: 2 additions & 55 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Build
run: npm run build
- name: Run Tests
run: npm run test:coverage -- --runInBand
run: npm run test:coverage -- --runInBand --passWithNoTests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
Expand All @@ -29,57 +29,4 @@ jobs:
fail-fast: false
matrix:
# run 3 copies of the current job in parallel
containers: [1, 2, 3]
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: cypress-io/github-action@v4
with:
start: npm start
wait-on: 'http://localhost:8080'
# only record the results to dashboard.cypress.io if CYPRESS_RECORD_KEY is set
record: ${{ !!secrets.CYPRESS_RECORD_KEY }}
# only do parallel if we have a record key
parallel: ${{ !!secrets.CYPRESS_RECORD_KEY }}
env:
# pass the Dashboard record key as an environment variable
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# pass GitHub token to allow accurately detecting a build vs a re-run build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# turn on code coverage when running npm start
# so far we've been using a webpack coverage-istanbul-loader for this
# but there has been work on using the code coverage support in the browser directly,
# which should be much faster
CODE_COVERAGE: true
# Also turn on the code coverage tasks in cypress itself, these are disabled
# by default.
CYPRESS_coverage: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
flags: cypress
s3-deploy:
name: S3 Deploy
needs:
- build_test
- cypress
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- name: Install Dependencies
run: npm ci
env:
# skip installing cypress since it isn't needed for just building
# This decreases the deploy time quite a bit
CYPRESS_INSTALL_BINARY: 0
- uses: concord-consortium/s3-deploy-action@v1
with:
bucket: models-resources
prefix: starter-projects
awsAccessKeyId: ${{ secrets.AWS_ACCESS_KEY_ID }}
awsSecretAccessKey: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# Parameters to GHActions have to be strings, so a regular yaml array cannot
# be used. Instead the `|` turns the following lines into a string
topBranches: |
["master"]
containers: [1, 2, 3]
24 changes: 0 additions & 24 deletions .github/workflows/release.yml

This file was deleted.

112 changes: 3 additions & 109 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,123 +1,17 @@
# Starter Projects
# CODAP Plugin API

## Development

### Copying a starter project

1. Create a new public repository for your project (e.g. `new-repository`)
2. Create a clone of the starter repo
```
git clone --single-branch https://github.com/concord-consortium/starter-projects.git new-repository
```
3. Update the starter repo
First, update and run the starter project:
```
cd new-repository
npm install
npm update
npm start
```
Then, verify the project works by visiting [localhost:8080](http://localhost:8080) and checking for the words "Hello World".
Also verify that the test suite still passes:
```
npm run test:full
```
If the updates are functional, please commit any changes to `package.json` or `package-lock.json` back to the
Starter Projects repository for future use.
4. Next, re-initialize the repo to create a new history
```
rm -rf .git
git init
```
5. Create an initial commit for your new project
```
git add .
git commit -m "Initial commit"
```
6. Push to your new repository
```
git remote add origin https://github.com/concord-consortium/new-repository.git
git push -u origin master
```
7. Open your new repository and update all instances of `starter-projects` to `new-repository` and `Starter Projects` to `New Repository`.
Note: this will do some of the configuration for GitHub Actions deployment to S3, but you'll still need to follow
the instructions [here](https://docs.google.com/document/d/e/2PACX-1vTpYjbGmUMxk_FswUmapK_RzVyEtm1WdnFcNByp9mqwHnp0nR_EzRUOiubuUCsGwzQgOnut_UiabYOM/pub).
8. To record the cypress tests results to the cypress dashboard service:
- go to https://dashboard.cypress.io
- create a new project
- go to the settings for the project
- in the github integration section choose the github repo to connect this project to
- copy the record key, and create a secret in the github repositories settings with the name CYPRESS_RECORD_KEY
- copy the Project ID and replace the value of `projectId` in cypress.json
9. Your new repository is ready! Remove this section of the `README`, and follow the steps below to use it.
### Initial steps
1. Clone this repo and `cd` into it
2. Run `npm install` to pull dependencies
3. Run `npm start` to run `webpack-dev-server` in development mode with hot module replacement
#### Run using HTTPS
Additional steps are required to run using HTTPS.
1. install [mkcert](https://github.com/FiloSottile/mkcert) : `brew install mkcert` (install using Scoop or Chocolatey on Windows)
2. Create and install the trusted CA in keychain if it doesn't already exist: `mkcert -install`
3. Ensure you have a `.localhost-ssl` certificate directory in your home directory (create if needed, typically `C:\Users\UserName` on Windows) and cd into that directory
4. Make the cert files: `mkcert -cert-file localhost.pem -key-file localhost.key localhost 127.0.0.1 ::1`
5. Run `npm run start:secure` to run `webpack-dev-server` in development mode with hot module replacement
Alternately, you can run secure without certificates in Chrome:
1. Enter `chrome://flags/#allow-insecure-localhost` in Chrome URL bar
2. Change flag from disabled to enabled
3. Run `npm run start:secure:no-certs` to run `webpack-dev-server` in development mode with hot module replacement
## This documentation is meant to be used by CODAP Plugin API developers.

### Building

If you want to build a local version run `npm build`, it will create the files in the `dist` folder.
You *do not* need to build to deploy the code, that is automatic. See more info in the Deployment section below.

### Notes

1. Make sure if you are using Visual Studio Code that you use the workspace version of TypeScript.
To ensure that you are open a TypeScript file in VSC and then click on the version number next to
`TypeScript React` in the status bar and select 'Use Workspace Version' in the popup menu.

## Deployment
Follow the instructions in this
[Guide](https://docs.google.com/document/d/1EacCSUhaHXaL8ll8xjcd4svyguEO-ipf5aF980-_q8E)
to setup an S3 & Cloudfront distribution that can be used with Github actions.
See also `s3_deploy.sh`, and `./github/ci.yml`.
Production releases to S3 are based on the contents of the /dist folder and are built automatically by GitHub Actions
for each branch and tag pushed to GitHub.
Branches are deployed to http://starter-projects.concord.org/branch/<name>.
If the branch name starts or ends with a number this number is stripped off.
Tags are deployed to http://starter-projects.concord.org/version/<name>.
To deploy a production release:
1. Increment version number in package.json
2. Create new entry in CHANGELOG.md
3. Run `git log --pretty=oneline --reverse <last release tag>...HEAD | grep '#' | grep -v Merge` and add contents (after edits if needed to CHANGELOG.md)
4. Run `npm run build`
5. Copy asset size markdown table from previous release and change sizes to match new sizes in `dist`
6. Create `release-<version>` branch and commit changes, push to GitHub, create PR and merge
7. Checkout master and pull
8. Create an annotated tag for the version, of the form `v[x].[y].[z]`, include at least the version in the tag message. On the command line this can be done with a command like `git tag -a v1.2.3 -m "1.2.3 some info about this version"`
9. Push the tag to github with a command like: `git push origin v1.2.3`.
10. Use https://github.com/concord-consortium/starter-projects/releases to make this tag into a GitHub release.
11. Run the release workflow to update http://starter-projects.concord.org/index.html.
1. Navigate to the actions page in GitHub and the click the "Release" workflow. This should take you to this page: https://github.com/concord-consortium/starter-projects/actions/workflows/release.yml.
2. Click the "Run workflow" menu button.
3. Type in the tag name you want to release for example `v1.2.3`. (Note this won't work until the PR has been merged to master)
4. Click the `Run Workflow` button.
### Testing

Run `npm test` to run jest tests. Run `npm run test:full` to run jest and Cypress tests.
Expand All @@ -142,6 +36,6 @@ Inside of your `package.json` file:

## License

Starter Projects are Copyright 2018 (c) by the Concord Consortium and is distributed under the [MIT license](http://www.opensource.org/licenses/MIT).
CODAP Plugin API are Copyright 2018 (c) by the Concord Consortium and is distributed under the [MIT license](http://www.opensource.org/licenses/MIT).

See license.md for the complete license text.
2 changes: 1 addition & 1 deletion cypress/e2e/workspace.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppElements as ae } from "../support/elements/app-elements"
import { AppElements as ae } from "../support/elements/app-elements";

context("Test the overall app", () => {
beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/elements/app-elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export const AppElements = {
getApp() {
return cy.get(".app");
}
}
};
Loading

0 comments on commit aa5027b

Please sign in to comment.