Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update assistest to suitable for grading submission that use ESLint > 9 #23

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
47fb90f
remove deployment action
dimasmds Sep 14, 2023
2561789
Merge pull request #1 from dicoding-dev/remove-irelevant-action
dimasmds Sep 14, 2023
af7e5a9
add test
dimasmds Sep 14, 2023
a14fa27
pass test
dimasmds Sep 14, 2023
ce51828
update yarn lock
dimasmds Sep 14, 2023
e08c664
Merge pull request #2 from dicoding-dev/feature/agrs-support-report
dimasmds Sep 14, 2023
41249f0
restructure experiment-storage
dimasmds Sep 14, 2023
dd3467d
install `del`
dimasmds Sep 14, 2023
8382b40
improve pathing
dimasmds Sep 14, 2023
2ed9e18
install del
dimasmds Sep 14, 2023
35d539a
remove all files in submission path
dimasmds Sep 14, 2023
9b0838b
Merge pull request #3 from dicoding-dev/feature/clean-up-after-review
dimasmds Sep 14, 2023
6d4b346
remove all files in submission path
dimasmds Sep 14, 2023
5193616
Merge pull request #4 from dicoding-dev/bugfix/acidentally-delete-report
dimasmds Sep 14, 2023
2ee14a9
use `ci` instead of `install` when package-lock.json available
dimasmds Sep 15, 2023
0fc1f0c
Merge pull request #5 from dicoding-dev/bugfix/using-ci-when-package-…
dimasmds Sep 15, 2023
3078c0c
update template
dimasmds Sep 18, 2023
de33b5c
fix test
dimasmds Sep 18, 2023
d0992bf
fix style
dimasmds Sep 18, 2023
96b7961
Merge pull request #6 from dicoding-dev/improvement/update-templating…
dimasmds Sep 18, 2023
8e8fc47
add support for yarn.lock
dimasmds Sep 19, 2023
9fee667
Merge pull request #7 from dicoding-dev/bugfix/add-support-yarn
dimasmds Sep 19, 2023
e65e73f
fix template
dimasmds Sep 19, 2023
ceaa226
fix wrong submission path
dimasmds Sep 19, 2023
0911712
remove lock freeze installation
dimasmds Sep 28, 2023
1bbd46f
Merge pull request #8 from dicoding-dev/improvement/remove-lock-support
dimasmds Sep 28, 2023
a055b32
Revert "Improvement/remove lock support after given write permission …
dimasmds Sep 28, 2023
cf6aa0d
Merge pull request #9 from dicoding-dev/revert-8-improvement/remove-l…
dimasmds Sep 28, 2023
0e49f04
disable package-lock in container
dimasmds Oct 3, 2023
8b88482
remove package-lock installation
dimasmds Oct 3, 2023
48ef8a2
Merge pull request #10 from dicoding-dev/improvement/disable-package-…
dimasmds Oct 3, 2023
659cf33
set agrs group to node user
habibimustafa Oct 10, 2023
6822b83
typo usermod
habibimustafa Oct 10, 2023
e509872
use group id
habibimustafa Oct 10, 2023
d3ec410
put default group id
habibimustafa Oct 10, 2023
23c187e
use assistest user
habibimustafa Oct 10, 2023
4a71d4b
put default group id
habibimustafa Oct 10, 2023
153eaa9
use assistest homebase
habibimustafa Oct 10, 2023
9533dea
modify homebase again
habibimustafa Oct 10, 2023
43504a0
put volume
habibimustafa Oct 10, 2023
57b225e
install gosu
habibimustafa Oct 10, 2023
f43501e
run as assistest with gosu
habibimustafa Oct 10, 2023
a22e38f
Merge pull request #11 from dicoding-dev/run-with-gosu
habibimustafa Oct 10, 2023
d63cf59
change user id
habibimustafa Oct 10, 2023
cf8c7fe
Merge pull request #12 from dicoding-dev/adjust-user
habibimustafa Oct 10, 2023
f7a5ba4
clean-up user
habibimustafa Oct 10, 2023
cf70ebe
clean-up group
habibimustafa Oct 10, 2023
e5d8a3f
Merge pull request #13 from dicoding-dev/clean-up-user
habibimustafa Oct 10, 2023
01c1b6d
fix user group again
habibimustafa Oct 10, 2023
5fb8623
add draft property
dimasmds Oct 23, 2023
e790832
add `draft` while generate report
dimasmds Oct 23, 2023
f940d32
add `draft` to `ReportGenerator`
dimasmds Oct 23, 2023
e542f3d
fix test
dimasmds Oct 23, 2023
b2ea7c7
add minimist types
dimasmds Nov 3, 2023
16f5e61
add `any` signature
dimasmds Nov 3, 2023
9c7e7d4
implement auto approve for Back-End Google Cloud
dimasmds Nov 3, 2023
3cd40d3
Merge pull request #14 from dicoding-dev/feature/enable-fully-auto-gr…
dimasmds Nov 3, 2023
591bbc9
ignore `eslint.config` from checking
dimasmds Apr 30, 2024
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
22 changes: 0 additions & 22 deletions .github/workflows/deploy.yml

This file was deleted.

19 changes: 11 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
FROM node:18-slim

RUN mkdir /student-app && chown -R node:node /student-app
RUN mkdir /report && chown -R node:node /report
RUN usermod -aG root node
RUN apt-get update && apt-get install -y gosu

WORKDIR /app
RUN chown -R node:node /app
USER node
RUN useradd -ms /bin/bash assistest

COPY --chown=node:node . .
RUN mkdir /home/assistest/app && chown -R assistest:assistest /home/assistest/app
RUN mkdir /home/assistest/student-app && chown -R assistest:assistest /home/assistest/student-app
RUN mkdir /home/assistest/report && chown -R assistest:assistest /home/assistest/report

WORKDIR /home/assistest/app
COPY --chown=assistest:assistest . .

RUN npm config set package-lock false
RUN yarn install --production=true

ENTRYPOINT ["sh", "entrypoint.sh"]
ENTRYPOINT ["/bin/bash", "entrypoint.sh"]
5 changes: 3 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
rm -f /reports/report.json || true
"$@"
rm -f /home/assistest/reports/report.json || true
chown -R assistest:assistest /home/assistest/student-app
exec gosu assistest "$@"
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"dependencies": {
"@types/node": "^18.8.4",
"axios": "^0.27.2",
"del": "^6.1.1",
"dotenv": "^16.0.3",
"minimist": "^1.2.7",
"newman": "^5.3.2",
Expand All @@ -27,6 +28,7 @@
},
"devDependencies": {
"@types/jest": "^29.1.2",
"@types/minimist": "^1.2.4",
"@types/newman": "^5.3.1",
"@typescript-eslint/eslint-plugin": "^5.40.0",
"@typescript-eslint/parser": "^5.40.0",
Expand Down
8 changes: 4 additions & 4 deletions src/config/review-template.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class CourseSubmissionReview {
rating: courseSubmissionAcception.rating,
message: courseSubmissionAcception.messages,
status: ReviewResultStatus.Approve,
checklist: this.submissionCriteriaCheck.reviewChecklistResult
checklist: this.submissionCriteriaCheck.reviewChecklistResult,
draft: false,
}
}

Expand All @@ -52,9 +53,10 @@ class CourseSubmissionReview {
rating: 0,
message: courseSubmissionRejection.messages,
status: ReviewResultStatus.Reject,
checklist: this.submissionCriteriaCheck.reviewChecklistResult
checklist: this.submissionCriteriaCheck.reviewChecklistResult,
draft: true,
}
}
}

export default CourseSubmissionReview
export default CourseSubmissionReview
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ interface ReviewResult {
rating: number,
message: string,
status: ReviewResultStatus,
checklist: SubmissionRequirement
checklist: SubmissionRequirement,
draft: boolean,
}

export enum ReviewResultStatus {
Approve = "Approve",
Reject = "Reject",
}

export default ReviewResult
export default ReviewResult
3 changes: 3 additions & 0 deletions src/interface/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {readdirSync} from "fs";
import ReportGenerator from "../service/report-generator/report-generator";
import * as path from "path";
import * as minimist from 'minimist';
import {sync} from "del";

class Cli {
private reportPath: string;
Expand Down Expand Up @@ -30,6 +31,8 @@ class Cli {
const submissionPath = path.resolve(this.folderPath)
const reviewResult = await main.reviewSubmission(submissionPath)
reportGenerator.generate(reviewResult, submissionPath)
// remove all files in submissionPath except report.json
sync([`${submissionPath}/**`, `!${submissionPath}/report.json`], { force: true })
}
}

Expand Down
11 changes: 6 additions & 5 deletions src/interface/implementation-test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import {readdirSync} from "fs";
import * as path from "path";
import {join} from "path";
import {main} from "../service-provider";
import ReportGenerator from "../service/report-generator/report-generator";

const reportGenerator = new ReportGenerator('./report')
async function run() {
const allSubmission = readdirSync('../experiment-storage/project')
const experimentStorageProjectPath = join(process.cwd(), 'experiment-storage', 'project')
const allSubmission = readdirSync(experimentStorageProjectPath)

for (const submission of allSubmission) {
console.log(`checking ${submission}`)
const submissionPath = path.resolve('../experiment-storage/project', submission)
const submissionPath = join(experimentStorageProjectPath, submission)
const reviewResult = await main.reviewSubmission(submissionPath)
reportGenerator.generate(reviewResult, submission)
const reportGenerator = new ReportGenerator(submissionPath)
reportGenerator.generate(reviewResult, submissionPath)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/service/eslint-checker/eslint-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class EslintChecker {

try {
//check eslint config available or not
execSync('npx eslint ./', {
execSync('npx eslint ./ --ignore-pattern \'eslint.config.*\'', {
cwd: submissionProject.packageJsonPath, stdio: "pipe"
})
const result = execSync('npx eslint ./ --rule \'linebreak-style:off\'', {
const result = execSync('npx eslint ./ --rule \'linebreak-style:off\' --ignore-pattern \'eslint.config.*\'', {
cwd: submissionProject.packageJsonPath,
stdio: "pipe"
})
Expand Down
22 changes: 20 additions & 2 deletions src/service/report-generator/report-generator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
import ReviewResult, {ReviewResultStatus} from "../../entities/review-result/course-submission-review/review-result";
import * as fs from "fs";

function itShouldMeetAGRSReportSpec(report: any): void {

Check warning on line 6 in src/service/report-generator/report-generator.test.ts

View workflow job for this annotation

GitHub Actions / lint (14.x)

Unexpected any. Specify a different type
expect(report.submission_id).toBeDefined()
expect(typeof report.submission_id).toEqual('number')
expect(report.message).toBeDefined()
expect(typeof report.message).toEqual('string')
expect(report.rating).toBeDefined()
expect(typeof report.rating).toEqual('number')
expect(report.is_passed).toBeDefined()
expect(typeof report.is_passed).toEqual('boolean')
expect(report.is_draft).toBeDefined()
expect(typeof report.is_draft).toEqual('boolean')
expect(report.checklist_keys).toBeDefined()
expect(Array.isArray(report.checklist_keys)).toEqual(true)
}

describe('checklist id resolver test', () => {
const reportGenerator = new ReportGenerator('./test/student/review-result/')

Expand All @@ -21,14 +36,17 @@
rating: 5,
status: ReviewResultStatus.Approve,
checklist: submissionRequirement,
message: 'Selamat'
message: 'Selamat',
draft: false,
}

const studentProjectPath = './test/student-project/project-with-correct-autoreview-config'
reportGenerator.generate(reviewResult, studentProjectPath)

const result = JSON.parse(fs.readFileSync('./test/student/review-result/report.json').toString())[0]

itShouldMeetAGRSReportSpec(result)

expect(result.checklist_keys).toEqual([
"project_have_correct_port",
"project_have_correct_runner_script",
Expand All @@ -38,7 +56,7 @@
"api_can_update_book",
"api_can_delete_book"
])
expect(result.message).toStrictEqual('<p>Hallo <strong>snder12</strong>, terima kasih telah sabar menunggu. Kami membutuhkan waktu untuk bisa memberikan <em>feedback</em> sekomprehensif mungkin kepada setiap peserta kelas. Dalam kesempatan ini ada &nbsp;4 (empat) hal yang ingin kami sampaikan.&nbsp;</p><p><strong>Pertama</strong>, kami ingin mengucapkan selamat! Karena kamu telah menyelesaikan tugas submission dari kelas Belajar Membuat Aplikasi Back-End untuk Pemula. Jangan lihat bintang yang kamu raih, tapi lihat kemajuan yang sudah kamu capai. Ingat semua <em>expert&nbsp;</em>dahulu pemula.&nbsp;</p><p><strong>K</strong><strong>edua</strong>, kamu boleh bangga karena telah menyelesaikan submission sesuai dengan kriteria yang telah kami tentukan. Mumpung masih hangat semangatnya langsung lanjut kelas selanjutnya yaitu <a href="https://www.dicoding.com/academies/266">Architecting on AWS (Membangun Arsitektur AWS di Cloud)</a> atau <a href="https://www.dicoding.com/academies/271">Belajar Fundamental Aplikasi Back-End</a>.&nbsp;</p><p><strong>Ketiga</strong>, beberapa lulusan tidak tahu mereka memiliki akses kelas selamanya. Sebagai informasi kelas Dicoding selalu <em>update&nbsp;</em>sehingga memiliki perbedaan minimal 30% dari sejak kelas dirilis. Silakan mampir kembali untuk melihat materi saat kamu membutuhkan <em>update</em>.&nbsp;</p><p><strong>K</strong><strong>eempat</strong>, karena sudah praktik langsung maka kamu sudah menguasai ilmu kelas dasar ini antara 75-90%. Salah satu cara agar meningkatkan penguasaan ilmu agar bisa lebih maksimal (&gt;90%) adalah dengan memperbanyak latihan atau mengajarkan ilmu kepada orang lain.</p><p>Salah satu misi Dicoding adalah menyebarkan ilmu yang bermanfaat. Kami berusaha membangun kurikulum standar global dengan harapan agar developer Indonesia bisa menjadi jawara di negeri sendiri. Namun misi ini tidak akan tercapai tanpa kolaborasi dari kita semua.</p><hr><p>Supaya aplikasimu menjadi lebih baik lagi, berikut <em>beberapa</em> <em>catatan</em> terkait submission kamu:</p><ul>Selamat</ul><hr><p>Silakan berkunjung ke <a href="https://www.dicoding.com/academies/261/discussions">academy discussion</a> untuk mengasah penguasaan ilmu kamu dan membuat ilmu yang kamu dapatkan bisa semakin berkah dan bermanfaat dengan membantu kawan-kawan kita yang saat ini masih berjuang.</p><p>Terima kasih telah membantu misi kami. Kesuksesan developer Indonesia adalah energi bagi kami. Jika memiliki pertanyaan atau saran terkait kelas, silakan email ke <a href="mailto:%[email protected]" rel="noreferrer noopener" target="_blank">[email protected]</a>.</p><hr><p style="text-align:right;"><em>Salam</em></p><p style="text-align:right;"><span style="color:rgb(226,80,65);">Dicoding Reviewer</span></p>')
expect(result.message).toStrictEqual('<p>Hallo <strong>snder12</strong>, terima kasih telah sabar menunggu. Kami membutuhkan waktu untuk bisa memberikan <em>feedback</em> sekomprehensif mungkin kepada setiap peserta kelas. Dalam kesempatan ini ada &nbsp;4 (empat) hal yang ingin kami sampaikan.&nbsp;</p><p><strong>Pertama</strong>, kami ingin mengucapkan selamat! Karena kamu telah menyelesaikan tugas submission dari kelas Belajar Membuat Aplikasi Back-End untuk Pemula. Jangan lihat bintang yang kamu raih, tapi lihat kemajuan yang sudah kamu capai. Ingat semua <em>expert&nbsp;</em>dahulu pemula.&nbsp;</p><p><strong>K</strong><strong>edua</strong>, kamu boleh bangga karena telah menyelesaikan submission sesuai dengan kriteria yang telah kami tentukan. Mumpung masih hangat semangatnya langsung lanjut kelas selanjutnya yaitu <a href="https://www.dicoding.com/academies/266">Architecting on AWS (Membangun Arsitektur AWS di Cloud)</a> atau <a href="https://www.dicoding.com/academies/271">Belajar Fundamental Aplikasi Back-End</a>.&nbsp;</p><p><strong>Ketiga</strong>, beberapa lulusan tidak tahu mereka memiliki akses kelas selamanya. Sebagai informasi kelas Dicoding selalu <em>update&nbsp;</em>sehingga memiliki perbedaan minimal 30% dari sejak kelas dirilis. Silakan mampir kembali untuk melihat materi saat kamu membutuhkan <em>update</em>.&nbsp;</p><p><strong>K</strong><strong>eempat</strong>, karena sudah praktik langsung maka kamu sudah menguasai ilmu kelas dasar ini antara 75-90%. Salah satu cara agar meningkatkan penguasaan ilmu agar bisa lebih maksimal (&gt;90%) adalah dengan memperbanyak latihan atau mengajarkan ilmu kepada orang lain.</p><p>Salah satu misi Dicoding adalah menyebarkan ilmu yang bermanfaat. Kami berusaha membangun kurikulum standar global dengan harapan agar developer Indonesia bisa menjadi jawara di negeri sendiri. Namun misi ini tidak akan tercapai tanpa kolaborasi dari kita semua.</p><hr><p>Supaya aplikasimu menjadi lebih baik lagi, berikut <em>beberapa</em> <em>catatan</em> terkait submission kamu:</p><ul>Selamat</ul><hr><p dir="ltr">Silakan berkunjung ke <a href="https://www.dicoding.com/academies/261/discussions" rel="noopener noreferrer" target="_blank">forum diskusi</a> untuk mengasah kembali penguasaan ilmu kamu dan membuat ilmu kamu bisa semakin bermanfaat dengan membantu developer yang lain.&nbsp;</p><p dir="ltr">Terima kasih telah membantu misi kami. Kesuksesan developer Indonesia adalah energi bagi kami. Jika memiliki pertanyaan terkait hasil submission, silakan mengikuti prosedur&nbsp;<a href="https://help.dicoding.com/academy-dicoding/prosedur-banding-hasil-review-submission-kelas" rel="noopener noreferrer" target="_blank">berikut</a>.</p><hr><p style="text-align: right;"><em>Salam</em></p><p style="text-align: right;"><span style="color: rgb(226, 80, 65);">Dicoding Reviewer</span></p>')
});
})

23 changes: 20 additions & 3 deletions src/service/report-generator/report-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import {existsSync, readFileSync, writeFileSync} from "fs";
import * as templates from "../../config/review-template.json";
import raiseDomainEvent from "../../common/domain-event";
import {join} from "path";

class ReportGenerator {
private readonly reportPath: string;
Expand All @@ -25,25 +26,41 @@
message: this.getReviewMessageWithTemplate(reviewResult, autoReviewConfig),
submission_path: submissionPath,
checklist: reviewResult.checklist,
checklist_keys: this.getCompletedChecklist(reviewResult)
checklist_keys: this.getCompletedChecklist(reviewResult),
is_passed: isApproved,
is_draft: this.getDraftDecision(isApproved, autoReviewConfig),
};

this.result.push(summary);
fs.mkdirSync(this.reportPath, {recursive: true});
const fileReportPath = join(this.reportPath, 'report.json')

writeFileSync(`${this.reportPath}/report.json`, JSON.stringify(this.result), {
writeFileSync(fileReportPath, JSON.stringify(this.result), {
mode: '0664'
})
raiseDomainEvent('report generated')
}

private getDraftDecision(isApproved: boolean, autoReviewConfig: any): boolean {

Check warning on line 44 in src/service/report-generator/report-generator.ts

View workflow job for this annotation

GitHub Actions / lint (14.x)

Unexpected any. Specify a different type
const allowedCoursesThatFullyGrading = [
342, // Back-End Pemula with Google Cloud
]

if (allowedCoursesThatFullyGrading.includes(autoReviewConfig.course_id)) {
// set `draft` to false, if approved is true
return !isApproved
}

return true
}

private getCompletedChecklist(reviewResult: ReviewResult) {
return Object.keys(reviewResult.checklist)
.filter(requirementName => reviewResult.checklist[requirementName].status)

}

getReviewMessageWithTemplate(reviewResult: ReviewResult, autoReviewConfig) {
getReviewMessageWithTemplate(reviewResult: ReviewResult, autoReviewConfig: any) {

Check warning on line 63 in src/service/report-generator/report-generator.ts

View workflow job for this annotation

GitHub Actions / lint (14.x)

Unexpected any. Specify a different type
const mainTemplate = templates.find(template => template.courseId === autoReviewConfig?.course_id)

if (!mainTemplate) {
Expand All @@ -63,7 +80,7 @@
}


private getAutoReviewConfig(projectPath: string): any | null {

Check warning on line 83 in src/service/report-generator/report-generator.ts

View workflow job for this annotation

GitHub Actions / lint (14.x)

Unexpected any. Specify a different type

const configFilePath = `${projectPath}/auto-review-config.json`
if (!existsSync(configFilePath)) {
Expand Down
Loading
Loading