Skip to content

Commit 0969cf4

Browse files
authored
Feature/update sudoku exercise (#23)
* Updated sudoku exercise - Moved from custom webpack configuration to use react-scripts to make things simpler. - Upgraded dependencies to latest ones. - Added linting and integration with codacy/codecov. - Added continuous integration examples of how to run tests on push/pull requests and how to "deploy" in github pages upon release. - Updated dockerfile to use an official node image so we don't have to install everything from scratch. - Updated sass examples to make them more interesting.
1 parent d04cb3b commit 0969cf4

File tree

19 files changed

+40059
-11685
lines changed

19 files changed

+40059
-11685
lines changed

.babelrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

.eslintrc.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"parser": "babel-eslint",
3+
"env": {
4+
"browser": true,
5+
"es6": true,
6+
"jest": true,
7+
"node": true
8+
},
9+
"settings": {
10+
"react": {
11+
"version": "16.13.1"
12+
}
13+
},
14+
"extends": [
15+
"eslint:recommended",
16+
"react",
17+
"plugin:react/recommended"
18+
],
19+
"plugins": [
20+
"react"
21+
]
22+
}

.github/workflows/release.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Release
2+
3+
on: release
4+
5+
jobs:
6+
unit-testing:
7+
name: Unit Tests
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: actions/setup-node@v1
12+
with:
13+
node-version: 13
14+
- name: install dependencies
15+
run: npm install
16+
- name: run tests
17+
run: npm test
18+
19+
deploy:
20+
name: Deploy to GitHub Pages
21+
runs-on: ubuntu-latest
22+
needs:
23+
- unit-testing
24+
steps:
25+
- uses: actions/checkout@v2
26+
- uses: actions/setup-node@v1
27+
with:
28+
node-version: 12.x
29+
- name: Install Packages
30+
run: npm install
31+
- name: Build page
32+
run: npm run build --verbose
33+
env:
34+
CI: false
35+
- name: Deploy to gh-pages
36+
uses: peaceiris/actions-gh-pages@v3
37+
with:
38+
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
39+
publish_dir: ./build

.github/workflows/testing.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Testing
2+
3+
on: push
4+
5+
jobs:
6+
unit-testing:
7+
name: Unit Tests
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: actions/setup-node@v1
12+
with:
13+
node-version: 13
14+
- name: install dependencies
15+
run: npm install
16+
- name: run tests
17+
run: npm run test:ci
18+
- name: Codecov
19+
uses: codecov/codecov-action@v2
20+
with:
21+
token: ${{ secrets.CODECOV_TOKEN }}
22+
flags: unittests

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ typings/
5959

6060
# next.js build output
6161
.next
62-
63-
public/css/*
64-
public/js/*
62+
.history/
63+
.vscode/
64+
build/

Dockerfile

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,21 @@
11
# -- Dockerfile -- #
22
#
33
# docker build -t react-exercise .
4-
# docker run -dit --name react-instance -v `pwd`:/storage/app -p 80:8080 react-exercise
4+
# docker run -dit --name react-instance -p 80:3000 react-exercise
55
# docker exec -it react-instance /bin/bash
66

7-
FROM ubuntu:16.04
7+
FROM node:12-buster
88

99
LABEL Description="React Sudoku" Version="1.0"
1010

11-
# Install generic tools
12-
RUN apt-get update && apt-get install -y \
13-
sudo \
14-
vim \
15-
net-tools \
16-
curl
11+
EXPOSE 3000
1712

18-
# Add node source repository to install the latest version
19-
RUN curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
13+
ARG APP_DIR="/opt/exercise-react"
2014

21-
# Install basic tools
22-
RUN apt-get update && apt-get install -y \
23-
nodejs
15+
RUN mkdir -p ${APP_DIR}
16+
WORKDIR ${APP_DIR}
2417

25-
# Bring the process starter
26-
COPY startup.sh /root/
27-
RUN chmod +x /root/startup.sh
18+
COPY . ${APP_DIR}
19+
RUN npm install
2820

29-
EXPOSE 8080
30-
31-
ENTRYPOINT [ "/root/startup.sh" ]
21+
ENTRYPOINT [ "npm", "run", "start" ]

EXERCISES.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,14 @@ All the exercises are possible and have been tested.
77

88
## Basic exercises
99

10-
1. Change color of the tiles the user has inserted a value.
10+
1. Change color of the tiles the user is editing at the moment.
1111

1212
This exercise involve only sass updates. [SASS](https://sass-lang.com/) and
1313
[CSS pseudo-classes](https://www.w3schools.com/css/css_pseudo_classes.asp)
1414

15-
2. Move navigation menu at the bottom of the Sudoku.
15+
2. When the sudoku is solved, show a message congratulating the user.
1616

17-
For this we don't need react, as we can't access the SudokuGame component thus it's
18-
not possible to move it freely as we would like.
19-
20-
As workaround, it's possible to use [jQuery](http://api.jquery.com/) directly to
21-
modify DOM elements however we want. Once the DOM is [ready](http://api.jquery.com/ready/),
22-
we should [manipulate](http://api.jquery.com/category/manipulation/) the element
23-
to move it wherever we want.
17+
For this we will need to understand the SudokuGame component and how to pass it callbacks.
2418

2519
## Medium exercises
2620

README.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
## Synopsis
1+
# Synopsis
2+
3+
[![Benchmark](https://github.com/gguridi/exercise-react/actions/workflows/release.yml/badge.svg?branch=master)](https://github.com/gguridi/exercise-react/actions/workflows/release.yml)
4+
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/d1cd1dc3fafb4086802a9a4a79b39189)](https://www.codacy.com/gh/gguridi/exercise-react/dashboard?utm_source=github.com&utm_medium=referral&utm_content=gguridi/exercise-react&utm_campaign=Badge_Grade)
5+
[![codecov](https://codecov.io/gh/gguridi/exercise-react/branch/master/graph/badge.svg?token=IUDIfrcUOY)](https://codecov.io/gh/gguridi/exercise-react)
26

37
This is a basic website intended to work with React and Bootstrap. This website gives a basic
48
functionality to show information in a responsive way.
@@ -13,7 +17,7 @@ The first thing to do is to [fork this repository](https://help.github.com/artic
1317
in your account. Once you have it forked you can clone it in your local environment
1418
with the command:
1519

16-
```
20+
```bash
1721
git clone {repo-url} ./local-folder
1822
```
1923

@@ -28,16 +32,16 @@ operating system you are running.
2832

2933
Once docker is installed, go to this folder and build the virtual machine with:
3034

31-
```
35+
```bash
3236
cd <path-to-this-code>
3337
docker build -t react-exercise .
3438
```
3539

3640
Then execute the following code to run the virtual machine. The webservice will be mapped automatically to the port 80
3741
of our local machine. (ensure no other process is running in the port 80 or it might conflict):
3842

39-
```
40-
docker run -dit --name react-instance -v `pwd`:/storage/app -p 80:8080 react-exercise
43+
```bash
44+
docker run -it --name react-instance -p 80:3000 react-exercise
4145
```
4246

4347
Note that the container has been created to run as an application. Once running it will
@@ -46,14 +50,14 @@ show the standard output and terminating the process will terminate also the con
4650
To connect to the container we can use (this will allow us to execute commands from
4751
inside the container using the bash shell):
4852

49-
```
53+
```bash
5054
docker exec -it react-instance /bin/bash
5155
```
5256

5357
If you need to rerun the virtual machine then we need to remove it first. Maybe the
5458
following commands will help you executing _docker run_ again.
5559

56-
```
60+
```bash
5761
docker stop react-instance
5862
docker rm react-instance
5963
```
@@ -72,15 +76,15 @@ operating system you are running.
7276
Then, from the folder we have cloned the code, we can see a `package.json` file.
7377
This file contains the dependencies of our project. To install them type:
7478

75-
```
79+
```bash
7680
npm install
7781
```
7882

7983
This will create a folder called `.node_modules` that will contain the dependencies.
8084

8185
Once the dependencies are there, we can start the development server with:
8286

83-
```
87+
```bash
8488
npm run start
8589
```
8690

@@ -113,7 +117,7 @@ The second one is installing them through npm. Then we include them as part of o
113117
React project and we let webpack, when builds the application, to manage the
114118
integration.
115119

116-
```
120+
```bash
117121
import 'jquery';
118122
import 'bootstrap/dist/js/bootstrap';
119123
```
@@ -134,7 +138,7 @@ The tests are located altogether with the code, under the .test.js extension.
134138

135139
We can run the tests from inside the container or from outside, with:
136140

137-
```
141+
```bash
138142
npm run test
139143
```
140144

0 commit comments

Comments
 (0)