Skip to content

Commit

Permalink
Fix issues with automatic deployment; switch to headful mode
Browse files Browse the repository at this point in the history
  • Loading branch information
gregbell26 committed Jul 3, 2024
1 parent cc1d262 commit 9b13af9
Show file tree
Hide file tree
Showing 10 changed files with 262 additions and 165 deletions.
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
dist
dist
node_modules
chrome
55 changes: 33 additions & 22 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,48 @@ permissions:
contents: read

jobs:
test-typescript:
name: TypeScript Tests
test-docker:
name: Docker Tests
runs-on: ubuntu-latest

# Run a local registry to push to
services:
registry:
image: registry:2
ports:
- 5001:5000

env:
TEST_TAG: localhost:5001/actions/hello-world-docer-action:latest

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
- name: Setup Docker BuildX
id: setup-buildx
uses: docker/setup-buildx-action@v3
with:
node-version-file: .node-version
cache: npm

- name: Install Dependencies
id: npm-ci
run: npm ci
install: true
driver-opts: network=host

- name: Check Format
id: npm-format-check
run: npm run format:check

- name: Lint
id: npm-lint
run: npm run lint
- name: Build the Container
id: build
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.TEST_TAG }}

- name: Test
id: npm-ci-test
run: npm run ci-test
- name: Run the Container
id: run
env:
INPUT_WHO_TO_GREET: Mona Lisa Octocat
run: |
docker run \
--env INPUT_WHO_TO_GREET="${{ env.INPUT_WHO_TO_GREET }}" \
--rm ${{ env.TEST_TAG }}
test-action:
name: GitHub Actions Test
Expand All @@ -57,7 +68,7 @@ jobs:
id: test-action
uses: ./
with:
milliseconds: 2000
who-to-greet: Mona Lisa Octocat

- name: Print Output
id: output
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.idea
dist
dist
chrome
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ runs:
using: docker
image: Dockerfile
args:
- /usr/bin/google-chrome
- ${{inputs.artifact_path}}
- ${{inputs.gradescope_assignment_id}}
- ${{inputs.course_id}}
Expand Down
112 changes: 44 additions & 68 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gradescope-cd-helper-action",
"version": "0.1.2",
"version": "1.0.0",
"description": "A GitHub Action to help with the automated deployment of gradescope autograders",
"repository": {
"type": "git",
Expand All @@ -25,8 +25,8 @@
"bundle": "npm run format:write && npm run package",
"ci-test": "npx jest",
"coverage": "npx make-coverage-badge --output-path ./badges/coverage.svg",
"format:write": "npx prettier --write .",
"format:check": "npx prettier --check .",
"format:write": "npx prettier --write src",
"format:check": "npx prettier --check src",
"lint": "npx eslint . -c ./.github/linters/.eslintrc.yml",
"package": "npx ncc build src/index.ts -o dist --source-map --license licenses.txt",
"package:watch": "npm run package -- --watch",
Expand Down Expand Up @@ -63,12 +63,14 @@
]
},
"dependencies": {
"puppeteer": "^22.12.0"
"puppeteer": "^22.10.0",
"which": "^4.0.0"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.0",
"@types/which": "^3.0.4",
"@typescript-eslint/eslint-plugin": "^7.11.0",
"@typescript-eslint/parser": "^7.11.0",
"@vercel/ncc": "^0.38.1",
Expand Down
31 changes: 27 additions & 4 deletions src/gradescope_assignment_uploader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import * as puppeteer from "puppeteer";

const GRADESCOPE_AUTOGRADER_SUBMIT_BUTTON_CLASS = ".js_submitAutograder";
const GRADESCOPE_AUTOGRADER_SUBMIT_BUTTON_CLASS = ".js-submitAutograder";
const GRADESCOPE_AUTOGRADER_FILE_UPLOAD = "input[type='file']";
const GRADESCOPE_AUTOGRADER_ERRORS_CLASS = ".js-autograderZipErrors";

export async function navigate_to_uploader_page(
page: puppeteer.Page,
Expand All @@ -16,29 +18,50 @@ export async function upload_zip_file(
gradescope_form_id: string,
path_to_zip: string,
): Promise<boolean> {
const upload_form = await page.$(gradescope_form_id);
const upload_form = await page.$(`#${gradescope_form_id}`);

if (upload_form === null) {
console.error("Failed to get upload form: " + gradescope_form_id);
return false;
}

const upload_input = await upload_form.$("input[type='upload']");
const upload_input = await upload_form.$(GRADESCOPE_AUTOGRADER_FILE_UPLOAD);

if (upload_input === null) {
console.error(
"Failed to get upload input: " + GRADESCOPE_AUTOGRADER_FILE_UPLOAD,
);
return false;
}

await upload_input.uploadFile(path_to_zip);

const uploader_errors = await upload_form.$(
GRADESCOPE_AUTOGRADER_ERRORS_CLASS,
);
if (uploader_errors === null) {
console.error("Failed to check for errors!");
return false;
}

if (await uploader_errors.isVisible()) {
console.error(await uploader_errors.evaluate((el) => el.textContent));
return false;
}

const upload_btn = await upload_form.$(
GRADESCOPE_AUTOGRADER_SUBMIT_BUTTON_CLASS,
);

if (upload_btn === null) {
console.error(
"Failed to get upload button: " +
GRADESCOPE_AUTOGRADER_SUBMIT_BUTTON_CLASS,
);
return false;
}

upload_btn.click();
await upload_btn.click();

return true;
}
Loading

0 comments on commit 9b13af9

Please sign in to comment.