Skip to content
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
Empty file added .github/.keep
Empty file.
224 changes: 213 additions & 11 deletions .github/workflows/classroom.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,221 @@
name: GitHub Classroom Workflow

on:
- push
- workflow_dispatch

name: Autograding Tests
'on':
- push
- workflow_dispatch
- repository_dispatch
permissions:
checks: write
actions: read
contents: read

jobs:
build:
name: Autograding
run-autograding-tests:
runs-on: ubuntu-latest
if: github.actor != 'github-classroom[bot]'
steps:
- uses: actions/checkout@v4
- uses: education/autograding@v1
- name: Checkout code
uses: actions/checkout@v4
- name: Step-1 Test
id: step-1-test
uses: education/autograding-command-grader@v1
with:
test-name: Step-1 Test
setup-command: npm install
command: npm run test:1
timeout: 10
max-score: 10
- name: Step-2 Test
id: step-2-test
uses: education/autograding-command-grader@v1
with:
test-name: Step-2 Test
setup-command: npm install
command: npm run test:2
timeout: 10
max-score: 10
- name: Step-3 Test
id: step-3-test
uses: education/autograding-command-grader@v1
with:
test-name: Step-3 Test
setup-command: npm install
command: npm run test:3
timeout: 10
max-score: 10
- name: Step-4 Test
id: step-4-test
uses: education/autograding-command-grader@v1
with:
test-name: Step-4 Test
setup-command: npm install
command: npm run test:4
timeout: 10
max-score: 10
- name: Step-5 Test
id: step-5-test
uses: education/autograding-command-grader@v1
with:
test-name: Step-5 Test
setup-command: npm install
command: npm run test:5
timeout: 10
max-score: 10
- name: Step-6 Test
id: step-6-test
uses: education/autograding-command-grader@v1
with:
test-name: Step-6 Test
setup-command: npm install
command: npm run test:6
timeout: 10
max-score: 10
- name: Step-7 Test
id: step-7-test
uses: education/autograding-command-grader@v1
with:
test-name: Step-7 Test
setup-command: npm install
command: npm run test:7
timeout: 10
max-score: 10
- name: Step-8 Test
id: step-8-test
uses: education/autograding-command-grader@v1
with:
test-name: Step-8 Test
setup-command: npm install
command: npm run test:8
timeout: 10
max-score: 10
- name: Step-9 Test
id: step-9-test
uses: education/autograding-command-grader@v1
with:
test-name: Step-9 Test
setup-command: npm install
command: npm run test:9
timeout: 10
max-score: 10
- name: Step-10 Test
id: step-10-test
uses: education/autograding-command-grader@v1
with:
test-name: Step-10 Test
setup-command: npm install
command: npm run test:10
timeout: 10
max-score: 10
- name: Step-11 Test
id: step-11-test
uses: education/autograding-command-grader@v1
with:
test-name: Step-11 Test
setup-command: npm install
command: npm run test:11
timeout: 10
max-score: 10
- name: Step-12 Test
id: step-12-test
uses: education/autograding-command-grader@v1
with:
test-name: Step-12 Test
setup-command: npm install
command: npm run test:12
timeout: 10
max-score: 10
- name: Step-13 Test
id: step-13-test
uses: education/autograding-command-grader@v1
with:
test-name: Step-13 Test
setup-command: npm install
command: npm run test:13
timeout: 10
max-score: 10
- name: Step-14 Test
id: step-14-test
uses: education/autograding-command-grader@v1
with:
test-name: Step-14 Test
setup-command: npm install
command: npm run test:14
timeout: 10
max-score: 10
- name: Step-15 Test
id: step-15-test
uses: education/autograding-command-grader@v1
with:
test-name: Step-15 Test
setup-command: npm install
command: npm run test:15
timeout: 10
max-score: 10
- name: Step-16 Test
id: step-16-test
uses: education/autograding-command-grader@v1
with:
test-name: Step-16 Test
setup-command: npm install
command: npm run test:16
timeout: 10
max-score: 10
- name: Step-17 Test
id: step-17-test
uses: education/autograding-command-grader@v1
with:
test-name: Step-17 Test
setup-command: npm install
command: npm run test:17
timeout: 10
max-score: 10
- name: Step-18 Test
id: step-18-test
uses: education/autograding-command-grader@v1
with:
test-name: Step-18 Test
setup-command: npm install
command: npm run test:18
timeout: 10
max-score: 10
- name: Step-19 Test
id: step-19-test
uses: education/autograding-command-grader@v1
with:
test-name: Step-19 Test
setup-command: npm install
command: npm run test:19
timeout: 10
max-score: 10
- name: Step-20 Test
id: step-20-test
uses: education/autograding-command-grader@v1
with:
test-name: Step-20 Test
setup-command: npm install
command: npm run test:20
timeout: 10
max-score: 10
- name: Autograding Reporter
uses: education/autograding-grading-reporter@v1
env:
STEP-1-TEST_RESULTS: "${{steps.step-1-test.outputs.result}}"
STEP-2-TEST_RESULTS: "${{steps.step-2-test.outputs.result}}"
STEP-3-TEST_RESULTS: "${{steps.step-3-test.outputs.result}}"
STEP-4-TEST_RESULTS: "${{steps.step-4-test.outputs.result}}"
STEP-5-TEST_RESULTS: "${{steps.step-5-test.outputs.result}}"
STEP-6-TEST_RESULTS: "${{steps.step-6-test.outputs.result}}"
STEP-7-TEST_RESULTS: "${{steps.step-7-test.outputs.result}}"
STEP-8-TEST_RESULTS: "${{steps.step-8-test.outputs.result}}"
STEP-9-TEST_RESULTS: "${{steps.step-9-test.outputs.result}}"
STEP-10-TEST_RESULTS: "${{steps.step-10-test.outputs.result}}"
STEP-11-TEST_RESULTS: "${{steps.step-11-test.outputs.result}}"
STEP-12-TEST_RESULTS: "${{steps.step-12-test.outputs.result}}"
STEP-13-TEST_RESULTS: "${{steps.step-13-test.outputs.result}}"
STEP-14-TEST_RESULTS: "${{steps.step-14-test.outputs.result}}"
STEP-15-TEST_RESULTS: "${{steps.step-15-test.outputs.result}}"
STEP-16-TEST_RESULTS: "${{steps.step-16-test.outputs.result}}"
STEP-17-TEST_RESULTS: "${{steps.step-17-test.outputs.result}}"
STEP-18-TEST_RESULTS: "${{steps.step-18-test.outputs.result}}"
STEP-19-TEST_RESULTS: "${{steps.step-19-test.outputs.result}}"
STEP-20-TEST_RESULTS: "${{steps.step-20-test.outputs.result}}"
with:
runners: step-1-test,step-2-test,step-3-test,step-4-test,step-5-test,step-6-test,step-7-test,step-8-test,step-9-test,step-10-test,step-11-test,step-12-test,step-13-test,step-14-test,step-15-test,step-16-test,step-17-test,step-18-test,step-19-test,step-20-test
4 changes: 2 additions & 2 deletions docs/tutorials/02.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
In this step we add the functionality to read from CSV files, since our DB would read from and write to CSV files, considering them as tables.

### 2.1 Create a Sample CSV File
Create a new CSV file in your project directory. Let's call it `sample.csv` and add some sample data to it:
Create a new CSV file in your project directory. Let's call it `student.csv` and add some sample data to it:

```csv
id,name,age
Expand Down Expand Up @@ -52,7 +52,7 @@ Example test:
const readCSV = require('../src/csvReader');

test('Read CSV File', async () => {
const data = await readCSV('./sample.csv');
const data = await readCSV('./student.csv');
expect(data.length).toBeGreaterThan(0);
expect(data.length).toBe(3);
expect(data[0].name).toBe('John');
Expand Down
8 changes: 4 additions & 4 deletions docs/tutorials/03.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Example implementation:
```javascript
// src/queryParser.js

function parseQuery(query) {
function parseSelectQuery(query) {
const selectRegex = /SELECT (.+) FROM (.+)/i;
const match = query.match(selectRegex);

Expand All @@ -26,7 +26,7 @@ function parseQuery(query) {
}
}

module.exports = parseQuery;
module.exports = parseSelectQuery;
```

### 3.2 Update Test to Check Query Parsing
Expand All @@ -36,11 +36,11 @@ Example test:
```javascript
// tests/index.test.js

const parseQuery = require('../src/queryParser');
const {parseSelectQuery} = require('../src/queryParser');

test('Parse SQL Query', () => {
const query = 'SELECT id, name FROM sample';
const parsed = parseQuery(query);
const parsed = parseSelectQuery(query);
expect(parsed).toEqual({
fields: ['id', 'name'],
table: 'sample'
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/04.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Here's a basic implementation:
```javascript
// src/index.js

const parseQuery = require('./queryParser');
const {parseSelectQuery} = require('./queryParser');
const readCSV = require('./csvReader');

async function executeSELECTQuery(query) {
const { fields, table } = parseQuery(query);
const { fields, table } = parseSelectQuery(query);
const data = await readCSV(`${table}.csv`);

// Filter the fields based on the query
Expand Down
8 changes: 4 additions & 4 deletions docs/tutorials/05.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Here's an updated implementation:
```javascript
// src/queryParser.js

function parseQuery(query) {
function parseSelectQuery(query) {
const selectRegex = /SELECT (.+?) FROM (.+?)(?: WHERE (.*))?$/i;
const match = query.match(selectRegex);

Expand All @@ -27,7 +27,7 @@ function parseQuery(query) {
}
}

module.exports = parseQuery;
module.exports = parseSelectQuery;
```

### 5.2 Run the Updated Tests
Expand All @@ -42,11 +42,11 @@ Example implementation:
```javascript
// src/index.js

const parseQuery = require('./queryParser');
const {parseSelectQuery} = require('./queryParser');
const readCSV = require('./csvReader');

async function executeSELECTQuery(query) {
const { fields, table, whereClause } = parseQuery(query);
const { fields, table, whereClause } = parseSelectQuery(query);
const data = await readCSV(`${table}.csv`);

// Filtering based on WHERE clause
Expand Down
10 changes: 5 additions & 5 deletions docs/tutorials/06.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Here's an example implementation:
```javascript
// src/queryParser.js

function parseQuery(query) {
function parseSelectQuery(query) {
const selectRegex = /SELECT (.+?) FROM (.+?)(?: WHERE (.*))?$/i;
const match = query.match(selectRegex);

Expand All @@ -36,7 +36,7 @@ function parseWhereClause(whereString) {
});
}

module.exports = parseQuery;
module.exports = parseSelectQuery;
```

> **💡Do it yourself:** Add error handling to the newly added function.
Expand All @@ -49,11 +49,11 @@ Here's an example implementation:
```javascript
// src/index.js

const parseQuery = require('./queryParser');
const {parseSelectQuery} = require('./queryParser');
const readCSV = require('./csvReader');

async function executeSELECTQuery(query) {
const { fields, table, whereClauses } = parseQuery(query);
const { fields, table, whereClauses } = parseSelectQuery(query);
const data = await readCSV(`${table}.csv`);

// Apply WHERE clause filtering
Expand Down Expand Up @@ -85,7 +85,7 @@ Example test:
```javascript
test('Parse SQL Query with Multiple WHERE Clauses', () => {
const query = 'SELECT id, name FROM sample WHERE age = 30 AND name = John';
const parsed = parseQuery(query);
const parsed = parseSelectQuery(query);
expect(parsed).toEqual({
fields: ['id', 'name'],
table: 'sample',
Expand Down
8 changes: 4 additions & 4 deletions docs/tutorials/08.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
In this step we implement the `JOIN` functionality from SQL.

### 8.1 Preparing CSV Files for INNER JOIN
- Rename `sample.csv` to `student.csv`
- Update the tests in `tests/index.test.js` to use `student.csv` instead of `sample.csv` and update the expected results accordingly.
- Rename `student.csv` to `student.csv`
- Update the tests in `tests/index.test.js` to use `student.csv` instead of `student.csv` and update the expected results accordingly.

### 8.2 Create a new Enrollment CSV File
This setup gives us two CSV files: one for student information and another for their course enrollments. We can now use these files to demonstrate the INNER JOIN functionality in the next step.
Expand Down Expand Up @@ -67,7 +67,7 @@ Example implementation:
```javascript
// src/queryParser.js

function parseQuery(query) {
function parseSelectQuery(query) {
// First, let's trim the query to remove any leading/trailing whitespaces
query = query.trim();

Expand Down Expand Up @@ -137,7 +137,7 @@ Example implementation:
// src/index.js at executeSELECTQuery

// Now we will have joinTable, joinCondition in the parsed query
const { fields, table, whereClauses, joinTable, joinCondition } = parseQuery(query);
const { fields, table, whereClauses, joinTable, joinCondition } = parseSelectQuery(query);
let data = await readCSV(`${table}.csv`);

// Perform INNER JOIN if specified
Expand Down
Loading