Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.

Add github actions to run tests and cleanup stale PRs #225

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
36 changes: 36 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!--

The title for your pull request should be made in this format

CITY CLASS_NO - FIRST_NAME LAST_NAME - MODULE - WEEK_NO

For example,

London Class 7 - Chris Owen - HTML/CSS - Week 1

Please complete the details below this message

-->

**Volunteers: Are you marking this coursework?** _You can find a guide on how to mark this coursework in `HOW_TO_MARK.md` in the root of this repository_

# Your Details

- Your Name:
- Your City:
- Your Slack Name:

# Homework Details

- Module:
- Week:

# Notes

- What did you find easy?

- What did you find hard?

- What do you still not understand?

- Any other notes?
17 changes: 17 additions & 0 deletions .github/workflows/close.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "Close stale issues and PRs"
on:
workflow_dispatch:
schedule:
- cron: "30 1 * * *"

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3
with:
stale-pr-message: "Your coursework submission has been closed because nobody has interacted with it in six weeks. You are welcome to re-open it to get more feedback."
days-before-stale: 42
days-before-close: 0
days-before-issue-stale: -1
days-before-issue-close: -1
14 changes: 14 additions & 0 deletions .github/workflows/extra-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Run extra tests
on:
pull_request:
paths:
- 3-extra/**
jobs:
extra-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install modules
run: npm install
- name: Run extra tests
run: npm test -- --selectProjects extra
11 changes: 11 additions & 0 deletions .github/workflows/mandatory-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Run mandatory tests
on: pull_request
jobs:
mandatory-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install modules
run: npm install
- name: Run mandatory tests
run: npm test -- --selectProjects mandatory
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Like learning a musical instrument, programming requires daily practise.

The exercises are split into three folders: `exercises`, `mandatory` and `extra`. All homework in the `exercise` and `mandatory` section **must** be completed for homework by the following lesson.
The exercises are split into three folders: `exercises`, `mandatory` and `extra`. All homework in the `exercise` and `mandatory` section **must** be completed for homework by the following lesson.

The `extra` folder contains exercises that you can complete to challenge yourself, but are not required for the following lesson.

Expand All @@ -13,11 +13,27 @@ https://github.com/CodeYourFuture/JavaScript-Core-1-Coursework-Week4-Solution

This is a **private** repository. Please request access from your Teachers, Buddy or City Coordinator after the start of your next lesson.

## Testing your work

- Each of the *.js files in the `1-exercises` folder can be run from the terminal using the `node` command with the path to the file. For example, `node 1-exercises/A-array-find/exercise.js` can be run from the root of the project.
- To run the tests in the `2-mandatory` folder, run `npm run test` from the root of the project (after having run `npm install` once before).
- To run the tests in the `3-extra` folder, run `npm run extra-tests` from the root of the project (after having run `npm install` once before).
## Running the code/tests

The files for the mandatory/extra exercises are intended to be run as jest tests.

- Once you have cloned the repository, run `npm install` once in the terminal to install jest (and any necessary dependencies).
- To run the tests for all mandatory/extra exercises, run `npm test`
- To run only the tests for the mandatory exercises, run `npm test -- --selectProjects mandatory`
- To run only the tests for the extra exercises, run `npm test -- --selectProjects extra`
- To run a single exercise/test (for example `2-mandatory/1-create-function.js`), run `npm test -- --testPathPattern 2-mandatory/1-create-function.js` (Remember, you can use tab-completion to get files relative to the current directory, so m`Tab ↹`/1-`Tab ↹` will autocomplete get you the test file starting with 1-)

For more information about tests, look here:

https://syllabus.codeyourfuture.io/guides/intro-to-tests

Try out variant way of running tests:

- `npm test` -> run all mandatory and extra tests
- `npm test -- --selectProjects mandatory` -> run only mandatory tests
- `npm test -- --testPathPattern 2-mandatory/1-create-function.js` -> run single test


## Instructions for submission

Expand Down
17 changes: 15 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"description": "Exercises for JS1 Week 4",
"license": "CC-BY-SA-4.0",
"scripts": {
"test": "jest --testRegex='mandatory[/\\\\].*\\.js$'",
"extra-tests": "jest --testRegex='extra[/\\\\].*\\.js$'"
"test": "jest"
},
"repository": {
"type": "git",
Expand All @@ -15,6 +14,20 @@
"url": "https://github.com/CodeYourFuture/JavaScript-Core-1-Coursework-Week4/issues"
},
"jest": {
"projects": [
{
"displayName": "mandatory",
"testMatch": [
"<rootDir>/2-mandatory/*.js"
]
},
{
"displayName": "extra",
"testMatch": [
"<rootDir>/3-extra/*.js"
]
}
],
"reporters": [
"default",
"<rootDir>/util/github-action-reporter.js"
Expand Down