Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
fix: upgrade cypress version to 7.x plus test updates (#1510)
Browse files Browse the repository at this point in the history
* fix: upgrade cypress version to 7.x

* trying chrome browser for cypress

* fix: cypress test fix and updates for v7

* update cypress to 7.1.0

* remove travis references

* sneaky updates to contributing section

* increase timeout

* increase timeout back to 20s

* add aimmo_runner/* in codecov ignore list

* update codecov ignore list

* GA to be triggered only on production

* minor updates to contributing section
  • Loading branch information
dionizh authored Apr 14, 2021
1 parent fb10e4e commit d1ee11b
Show file tree
Hide file tree
Showing 10 changed files with 209 additions and 152 deletions.
11 changes: 8 additions & 3 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@ coverage:
range: "70...100"

ignore:
- ".travis.yml"
- "aimmo_setup.py"
- "all_tests.py"
- "run.py"
- "docs/*"
- "docs/**/*"
- "aimmo/static/pyodide/**/*"
- "docs/**/**/*"
- "aimmo/static/*"
- "aimmo/static/**/*"
- "aimmo/static/**/**/*"
- "aimmo-game/agones/*"
- "aimmo-game/agones/**/*"
- "aimmo_runner/*"
- "aimmo_runner/**/*"
- "test_utils/**/*"
- "test_utils/*"

comment:
layout: "reach, diff, flags, files"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
- name: Run Cypress tests
uses: cypress-io/github-action@v2
with:
browser: chrome
install: false
start: python ../run.py -c
working-directory: game_frontend
Expand Down
50 changes: 12 additions & 38 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,21 @@
* Need help with [git](https://git-scm.com/docs/gittutorial)?
* The [issues are listed on ocadotechnology/aimmo](https://github.com/ocadotechnology/aimmo/issues).
It's even better if you're using [ZenHub](https://www.zenhub.com/) because it will allow you to look at a [Kanban-ish board](https://github.com/ocadotechnology/aimmo/issues#boards) for the project.
The new starter / up-for-grabs issues are listed with the [help wanted label](https://github.com/ocadotechnology/aimmo/labels/help%20wanted)

Check the list selected as ["good first issue" here](https://github.com/ocadotechnology/aimmo/contribute).
## Now you want to **test** your changes and **run** the project locally...
* To work on the project, you can use whichever editor you like. Lots here like [IntelliJ or PyCharm](https://www.jetbrains.com/), for instance.
* As said in the [readme](https://github.com/ocadotechnology/aimmo), you should set up a virtual environment.
* e.g. the first time, `mkvirtualenv -a path/to/aimmo aimmo`
* and thereafter: `workon aimmo`
* You can test your change by running the test suite - you can go to the root of the project and type: `python example_project/manage.py test` ; but Travis uses `python setup.py test` (will also install stuff in your virtualenv needed for the tests)
* To manually test things and run the project, `./run` in the root.
* To work on the project, you can use whichever editor you like. Recommended: [VSCode](https://code.visualstudio.com/) with [black formatter](https://black.readthedocs.io/en/stable/) installed.
* Follow the [setup guideline here](https://github.com/ocadotechnology/aimmo/blob/development/docs/usage.md).
* You can test your change by running the test suite: `pytest`.
* Don't forget to add comments if you think they will help other people to understand your code.

## Great, you can **commit**, open a **Pull Request**, and we'll **review** it...
## Great, you can **push** your changes, open a **Pull Request**, and someone in the core team will **review** it...

Before you merge:
- Your PR should be connected to a corresponing ZenHub issue.
- Your PR title must follow the [semantic PR](https://github.com/zeke/semantic-pull-requests). Basically use `feat:` prefix for feature, and `fix:` prefix for bug fixes.
- Your PR should be connected to a corresponding ZenHub issue.
- All required status checks must pass.
- Add documentation if necessary

* Do not accept a PR yourself - at least someone else should review your code and approve it first.

### When a PR is accepted

1. It will be merged into the development branch
2. A new beta version of Kurono will be released on PyPI and Docker Hub
3. The beta will be tested on our staging servers

Eventually, development will be merged into master. This will trigger a stable release which will make its way up to production. Congrats! 🎉

***Note:*** *See [Life Cycle Of A Code Change](docs/life-cycle-of-a-code-change.md) for details on the pipeline a code change is submitted to after the PR is approved.*

## Some conventions to keep in mind...
We follow PEP8 convention quite strictly however we do make a few exceptions to this rule. They are as follows:

#### Maximum Line Length
PEP8 specifies that the maximum line length is to be limited to *79 characters* with some lines even shorter than this. We replace this rule and try to stick to *90 characters*.
- We use [Reviewable](https://reviewable.io/) for code reviews. Keep an eye on notifications from reviewable. You might need to go back, revise your code and push the changes again. Repeat until the PR is accepted.
## When a PR is accepted

#### Line Breaking after/before binary operators
The internet seems to be divided and PEP8 had some major changes when it comes to this rule. We have agreed that we want to strictly use binary operators on the **next** line, as opposed to before the line break.
- It will be merged into the development branch and will get deployed into [the staging server](https://staging-dot-decent-digit-629.appspot.com/)

#### Indentation on line breaks
The indentation should be kept consistent by the use of **parenthesis** appropriately. Example:
```python
if (cell.location != always_empty_location
and random.random() < self.settings['OBSTACLE_RATIO']):
```
- Eventually, what's on staging will make its way up to [production](https://www.codeforlife.education/). Congrats! 🎉
12 changes: 1 addition & 11 deletions aimmo_runner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,7 @@

from .shell_api import log, run_command, run_command_async

sys.path.append("/home/travis/build/ocadotechnology/aimmo")

try:
if os.environ["CI"] == "true":
ROOT_DIR_LOCATION = os.environ["TRAVIS_BUILD_DIR"]
else:
ROOT_DIR_LOCATION = os.path.abspath(
os.path.dirname((os.path.dirname(__file__)))
)
except KeyError:
ROOT_DIR_LOCATION = os.path.abspath(os.path.dirname((os.path.dirname(__file__))))
ROOT_DIR_LOCATION = os.path.abspath(os.path.dirname((os.path.dirname(__file__))))

_MANAGE_PY = os.path.join(ROOT_DIR_LOCATION, "example_project", "manage.py")
_FRONTEND_BUNDLER_JS = os.path.join(
Expand Down
14 changes: 10 additions & 4 deletions game_frontend/cypress/fixtures/gameState.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
},
"players": [
{
"location": { "x": 1, "y": 1 },
"location": {
"x": 1,
"y": 1
},
"health": 10,
"score": 10,
"backpack": {},
Expand All @@ -21,7 +24,7 @@
],
"interactables": [
{
"type": "artefact",
"type": "yellow_orb",
"location": {
"x": -8,
"y": 15
Expand All @@ -30,7 +33,10 @@
],
"obstacles": [
{
"location": { "x": 2, "y": 2 },
"location": {
"x": 2,
"y": 2
},
"width": 1,
"height": 1,
"type": "wall",
Expand All @@ -39,4 +45,4 @@
],
"turnCount": 1
}
}
}
7 changes: 4 additions & 3 deletions game_frontend/cypress/support/avatarCodeTester.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

export function testAvatarCode (avatarCode, expectedAction, expectedLog) {
export function testAvatarCode(avatarCode, expectedAction, expectedLog) {
cy.loadGameWithAvatarCode(avatarCode)

cy.fixture('gameState.json').then(gameState => {
Expand All @@ -12,7 +12,8 @@ export function testAvatarCode (avatarCode, expectedAction, expectedLog) {
checkComputedTurnResult(expectedAction, expectedLog)
}

export function checkComputedTurnResult (expectedAction, expectedLog) {
export function checkComputedTurnResult(expectedAction, expectedLog) {

const getComputedTurnResult = win => {
const state = win.store.getState()
return state.action.avatarAction
Expand All @@ -21,7 +22,7 @@ export function checkComputedTurnResult (expectedAction, expectedLog) {
cy.window()
.pipe(getComputedTurnResult)
.should(computedTurnResult => {
expect(computedTurnResult).to.not.be.undefined
assert.isObject(computedTurnResult)

const avatarAction = computedTurnResult.action
const avatarLog = computedTurnResult.log
Expand Down
6 changes: 1 addition & 5 deletions game_frontend/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@ Cypress.Commands.add('visitAGame', () => {
})

Cypress.Commands.add('loadGameWithAvatarCode', avatarCode => {
cy.server().route({
method: 'GET',
url: '/kurono/api/code/*',
response: avatarCode
})
cy.intercept('GET', '/kurono/api/code/*', avatarCode)

cy.visitAGame()

Expand Down
5 changes: 3 additions & 2 deletions game_frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"babel-eslint": "^10.1.0",
"babel-plugin-module-resolver": "^3.2.0",
"babel-plugin-transform-optional-chaining": "^7.0.0-beta.3",
"cypress": "^4.7.0",
"cypress": "^7.1.0",
"cypress-pipe": "^1.7.0",
"cypress-terminal-report": "^1.4.2",
"enzyme": "^3.10.0",
Expand Down Expand Up @@ -91,6 +91,7 @@
],
"scripts": {
"lint": "eslint 'src/**/*.{js,ts}'",
"test": "jest"
"test": "jest",
"cypress:open": "cypress open"
}
}
8 changes: 5 additions & 3 deletions game_frontend/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ WebFont.load({

ReactGA.initialize('UA-49883146-1', {
debug: false,
testMode: process.env.NODE_ENV === 'test'
testMode: process.env.NODE_ENV !== 'production'
})

ReactGA.pageview(`/kurono/play/${getGameIDFromURL()}`)
if (process.env.NODE_ENV === 'production') {
ReactGA.pageview(`/kurono/play/${getGameIDFromURL()}`)
}

const initialState = (window.Cypress && window.initialState) || {
editor: {
Expand All @@ -55,7 +57,7 @@ const initialState = (window.Cypress && window.initialState) || {
}
}

function getGameIDFromURL () {
function getGameIDFromURL() {
const url = window.location.href
const gameIDFinder = /\/play\/([0-9]+)/
return gameIDFinder.exec(url)[1]
Expand Down
Loading

0 comments on commit d1ee11b

Please sign in to comment.