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

Run with gosu #22

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 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
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.

22 changes: 14 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
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
ARG AGRSGROUP=1004

WORKDIR /app
RUN chown -R node:node /app
USER node
RUN apt-get update && apt-get install -y gosu

COPY --chown=node:node . .
RUN groupadd --force -g $AGRSGROUP assistest
RUN useradd -ms /bin/bash --no-user-group -g $AGRSGROUP -u 1337 assistest

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 "$@"
1 change: 1 addition & 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 Down
8 changes: 4 additions & 4 deletions src/config/review-template.json

Large diffs are not rendered by default.

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
19 changes: 18 additions & 1 deletion 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 @@ -29,6 +44,8 @@

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 +55,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>')
});
})

8 changes: 6 additions & 2 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,13 +26,16 @@
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: true,
};

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')
Expand Down Expand Up @@ -63,7 +67,7 @@
}


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

Check warning on line 70 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