From 1374c7283a607b1c1e71037a56861bb55386185c Mon Sep 17 00:00:00 2001 From: IDzyre Date: Thu, 6 Mar 2025 19:05:36 -0300 Subject: [PATCH 01/12] Add home creation ansible script --- .../playbooks/submitty_homework_creation.yml | 22 +++ .../files/config_files/file_homework.json | 162 ++++++++++++++++++ .../files/json_list.txt | 1 + .../tasks/create_gradeable.yml | 16 ++ .../submitty_homework_creation/tasks/main.yml | 34 ++++ 5 files changed, 235 insertions(+) create mode 100644 .setup/ansible/playbooks/submitty_homework_creation.yml create mode 100644 .setup/ansible/roles/submitty_homework_creation/files/config_files/file_homework.json create mode 100644 .setup/ansible/roles/submitty_homework_creation/files/json_list.txt create mode 100644 .setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml create mode 100644 .setup/ansible/roles/submitty_homework_creation/tasks/main.yml diff --git a/.setup/ansible/playbooks/submitty_homework_creation.yml b/.setup/ansible/playbooks/submitty_homework_creation.yml new file mode 100644 index 00000000000..2a4d42754f1 --- /dev/null +++ b/.setup/ansible/playbooks/submitty_homework_creation.yml @@ -0,0 +1,22 @@ +--- +- name: Submitty Homework Creation + hosts: localhost + connection: local + + roles: + # This role is defined in the Submitty Repo under .setup/ansible/roles + - role: submitty_homework_api # noqa syntax-check[specific] + - role: submitty_homework_api # noqa syntax-check[specific] + vars: + vcs: https://github.com/IDzyre/Tutorial.git # This is a fork of the Submitty tutorial repository with an added folder for the config files, I will ask on Monday if I could/should put it in the actual tutorial repository. + + vars_prompt: + - name: api_url + prompt: Enter the full API url (http://{domain.com}/api/{semester}/{course}/upload) + private: no + - name: passed_api_key + prompt: Enter your API key + private: yes + - name: vcs + prompt: Enter clone URL for Git repository if you are using one + private: no diff --git a/.setup/ansible/roles/submitty_homework_creation/files/config_files/file_homework.json b/.setup/ansible/roles/submitty_homework_creation/files/config_files/file_homework.json new file mode 100644 index 00000000000..9f7ec77f51b --- /dev/null +++ b/.setup/ansible/roles/submitty_homework_creation/files/config_files/file_homework.json @@ -0,0 +1,162 @@ +{ + "title": "Homework from file", + "type": "Electronic File", + "id": "file_homework", + "instructions_url": "", + "syllabus_bucket": "homework", + "autograding_config_path": "\/usr\/local\/submitty\/more_autograding_examples\/python_simple_homework\/config", + "bulk_upload": false, + "ta_grading": "true", + "grade_inquiries": "true", + "dates": { + "ta_view_start_date": "1970-01-01 23:59:59", + "grade_start_date": "9997-12-31 23:59:59", + "grade_due_date": "9998-12-31 23:59:59", + "grade_released_date": "9998-12-31 23:59:59", + "team_lock_date": "1971-01-01 23:59:59", + "submission_open_date": "1971-01-01 23:59:59", + "submission_due_date": "9996-12-31 23:59:59", + "grade_inquiry_start_date": "9999-01-01 23:59:59", + "grade_inquiry_due_date": "9999-01-06 23:59:59", + "has_due_date": true, + "has_release_date": true, + "late_submission_allowed": true, + "late_days": 0 + }, + "rubric": [ + { + "title": "Read Me", + "ta_comment": "Reward student for including docstrings.", + "student_comment": "Code should be organized into logical and intuitive functions.", + "lower_clamp": 0, + "default": 2, + "max_value": 2, + "upper_clamp": 2, + "text": false, + "peer_component": false, + "page": 0, + "is_itempool_linked": false, + "itempool": "", + "marks": [ + { + "points": 0, + "title": "Full Credit", + "publish": false + }, + { + "points": -1, + "title": "Minor errors in Read Me", + "publish": false + }, + { + "points": -2, + "title": "Major errors in Read Me or Read Me missing", + "publish": false + } + ] + }, + { + "title": "Coding Style", + "ta_comment": "Deduct points if the student uses global variables.", + "student_comment": "The use of builtin functions is prohibited for this exercise.", + "lower_clamp": 0, + "default": 5, + "max_value": 5, + "upper_clamp": 5, + "text": false, + "peer_component": false, + "page": 0, + "is_itempool_linked": false, + "itempool": "", + "marks": [ + { + "points": 0, + "title": "Full Credit", + "publish": false + }, + { + "points": -5, + "title": "Code is unreadable", + "publish": false + }, + { + "points": -3, + "title": "Code is very difficult to understand", + "publish": false + }, + { + "points": -1, + "title": "Code is difficult to understand", + "publish": false + } + ] + }, + { + "title": "Documentation", + "ta_comment": "Reward student for properly using divide and conquer in code.", + "student_comment": "Code should be broken down into functions that each solve a part of the problem.", + "lower_clamp": 0, + "default": 5, + "max_value": 5, + "upper_clamp": 5, + "text": false, + "peer_component": false, + "page": 0, + "is_itempool_linked": false, + "itempool": "", + "marks": [ + { + "points": 0, + "title": "Full Credit", + "publish": false + }, + { + "points": -5, + "title": "No documentation", + "publish": false + }, + { + "points": -3, + "title": "Very little documentation or documentation makes no sense", + "publish": false + }, + { + "points": -1, + "title": "Way too much documentation and\/or documentation makes no sense", + "publish": false + } + ] + }, + { + "title": "Extra Credit", + "ta_comment": "Deduct points if the student uses global variables.", + "student_comment": "A switch case should be used and not the if-else structure.", + "lower_clamp": 0, + "default": 0, + "max_value": 0, + "upper_clamp": 5, + "text": false, + "peer_component": false, + "page": 0, + "is_itempool_linked": false, + "itempool": "", + "marks": [ + { + "points": 0, + "title": "No Credit", + "publish": false + }, + { + "points": 2, + "title": "Extra credit done poorly", + "publish": false + }, + { + "points": 5, + "title": "Extra credit is acceptable", + "publish": false + } + ] + } + ] +} \ No newline at end of file diff --git a/.setup/ansible/roles/submitty_homework_creation/files/json_list.txt b/.setup/ansible/roles/submitty_homework_creation/files/json_list.txt new file mode 100644 index 00000000000..b22ba4b175c --- /dev/null +++ b/.setup/ansible/roles/submitty_homework_creation/files/json_list.txt @@ -0,0 +1 @@ +config_files/file_homework.json \ No newline at end of file diff --git a/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml b/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml new file mode 100644 index 00000000000..e79e7f15571 --- /dev/null +++ b/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml @@ -0,0 +1,16 @@ +- name: Create gradeables with API + ansible.builtin.uri: + url: "{{ api_url }}" + method: POST + body_format: json + body: "{{ lookup('file', var_json_file) }}" + return_content: yes + headers: + Authorization: "{{ api_key }}" + register: api_response + +- name: Fail when status is error + fail: + msg: "{{ (api_response.content | from_json).message }}" + when: + - (api_response.content | from_json).status != 'success' diff --git a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml new file mode 100644 index 00000000000..6574bd701bf --- /dev/null +++ b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml @@ -0,0 +1,34 @@ +- name: Checkout repository containing config files + ansible.builtin.git: + repo: "{{ vcs }}" + dest: /tmp/Submitty + force: yes + update: yes + when: vcs != '' + +- name: Find files in the directory + ansible.builtin.find: + paths: "/tmp/Submitty/config_files/" # Replace with your directory path + file_type: file # Ensure you're finding files (not directories) + register: json_files + when: vcs != '' + +- name: Set a variable with the list of file paths + ansible.builtin.set_fact: + var_json_list: "{{ json_files.files | map(attribute='path') | list }}" + when: vcs != '' + +- name: Read JSON content from a file + ansible.builtin.set_fact: + var_json_list: "{{ lookup('file', 'json_list.txt') | split('\n') }}" + when: vcs == '' + +- name: Use task list to loop through gradeables + ansible.builtin.include_tasks: + file: create_gradeable.yml + loop: "{{ var_json_list }}" + loop_control: + loop_var: submitty_homework_api_json_file + vars: + var_json_file: "{{ submitty_homework_api_json_file }}" + api_key: "{{ passed_api_key }}" From 9741a98b0c287ca616e1dd4e7c5220fe42a5c6b6 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Thu, 6 Mar 2025 22:16:17 -0300 Subject: [PATCH 02/12] linting --- .setup/ansible/playbooks/submitty_homework_creation.yml | 8 ++++---- .../submitty_homework_creation/tasks/create_gradeable.yml | 6 +++--- .../roles/submitty_homework_creation/tasks/main.yml | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.setup/ansible/playbooks/submitty_homework_creation.yml b/.setup/ansible/playbooks/submitty_homework_creation.yml index 2a4d42754f1..c3035271d6d 100644 --- a/.setup/ansible/playbooks/submitty_homework_creation.yml +++ b/.setup/ansible/playbooks/submitty_homework_creation.yml @@ -2,13 +2,13 @@ - name: Submitty Homework Creation hosts: localhost connection: local - + roles: # This role is defined in the Submitty Repo under .setup/ansible/roles - - role: submitty_homework_api # noqa syntax-check[specific] - - role: submitty_homework_api # noqa syntax-check[specific] + - role: submitty_homework_api + - role: submitty_homework_api vars: - vcs: https://github.com/IDzyre/Tutorial.git # This is a fork of the Submitty tutorial repository with an added folder for the config files, I will ask on Monday if I could/should put it in the actual tutorial repository. + vcs: https://github.com/IDzyre/Tutorial.git # This is a fork of the Submitty tutorial repository with an added folder for the config files, I will ask on Monday if I could/should put it in the actual tutorial repository. vars_prompt: - name: api_url diff --git a/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml b/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml index e79e7f15571..ae22cd27d42 100644 --- a/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml +++ b/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml @@ -5,12 +5,12 @@ body_format: json body: "{{ lookup('file', var_json_file) }}" return_content: yes - headers: + headers: Authorization: "{{ api_key }}" register: api_response - name: Fail when status is error - fail: + ansible.builtin.fail: msg: "{{ (api_response.content | from_json).message }}" - when: + when: - (api_response.content | from_json).status != 'success' diff --git a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml index 6574bd701bf..bb2152612b4 100644 --- a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml +++ b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml @@ -4,6 +4,7 @@ dest: /tmp/Submitty force: yes update: yes + version: "main" when: vcs != '' - name: Find files in the directory From b9211133fb5bafd8194aaa68eca098d2b651949a Mon Sep 17 00:00:00 2001 From: IDzyre Date: Fri, 7 Mar 2025 10:42:50 -0300 Subject: [PATCH 03/12] Try to fix git linting? --- .setup/ansible/playbooks/submitty_homework_creation.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.setup/ansible/playbooks/submitty_homework_creation.yml b/.setup/ansible/playbooks/submitty_homework_creation.yml index c3035271d6d..d3e99259c6a 100644 --- a/.setup/ansible/playbooks/submitty_homework_creation.yml +++ b/.setup/ansible/playbooks/submitty_homework_creation.yml @@ -5,8 +5,8 @@ roles: # This role is defined in the Submitty Repo under .setup/ansible/roles - - role: submitty_homework_api - - role: submitty_homework_api + - role: submitty_homework_creation + - role: submitty_homework_creation vars: vcs: https://github.com/IDzyre/Tutorial.git # This is a fork of the Submitty tutorial repository with an added folder for the config files, I will ask on Monday if I could/should put it in the actual tutorial repository. From f579e592b52c8939d1232c8ef5d338b14b416d51 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 11 Mar 2025 15:10:11 -0300 Subject: [PATCH 04/12] Fix ansible lint --- .../ansible/playbooks/submitty_homework_creation.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.setup/ansible/playbooks/submitty_homework_creation.yml b/.setup/ansible/playbooks/submitty_homework_creation.yml index d3e99259c6a..832ecaad53b 100644 --- a/.setup/ansible/playbooks/submitty_homework_creation.yml +++ b/.setup/ansible/playbooks/submitty_homework_creation.yml @@ -3,10 +3,14 @@ hosts: localhost connection: local - roles: + tasks: # This role is defined in the Submitty Repo under .setup/ansible/roles - - role: submitty_homework_creation - - role: submitty_homework_creation + - name: Create gradeable + ansible.builtin.include_role: + name: submitty_homework_creation + - name: Create gradeable + ansible.builtin.include_role: + name: submitty_homework_creation vars: vcs: https://github.com/IDzyre/Tutorial.git # This is a fork of the Submitty tutorial repository with an added folder for the config files, I will ask on Monday if I could/should put it in the actual tutorial repository. From 6195ef0067594294db225c9dbaa1f3a408642750 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 11 Mar 2025 18:23:49 -0300 Subject: [PATCH 05/12] Change variable names --- .setup/ansible/playbooks/submitty_homework_creation.yml | 6 +++--- .../submitty_homework_creation/tasks/create_gradeable.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.setup/ansible/playbooks/submitty_homework_creation.yml b/.setup/ansible/playbooks/submitty_homework_creation.yml index 832ecaad53b..38408b9e111 100644 --- a/.setup/ansible/playbooks/submitty_homework_creation.yml +++ b/.setup/ansible/playbooks/submitty_homework_creation.yml @@ -15,12 +15,12 @@ vcs: https://github.com/IDzyre/Tutorial.git # This is a fork of the Submitty tutorial repository with an added folder for the config files, I will ask on Monday if I could/should put it in the actual tutorial repository. vars_prompt: - - name: api_url + - name: submitty_homework_creation_api_url prompt: Enter the full API url (http://{domain.com}/api/{semester}/{course}/upload) private: no - - name: passed_api_key + - name: submitty_homework_creation_passed_api_key prompt: Enter your API key private: yes - - name: vcs + - name: submitty_homework_creation_vcs prompt: Enter clone URL for Git repository if you are using one private: no diff --git a/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml b/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml index ae22cd27d42..4375810b7a1 100644 --- a/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml +++ b/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml @@ -1,12 +1,12 @@ - name: Create gradeables with API ansible.builtin.uri: - url: "{{ api_url }}" + url: "{{ submitty_homework_creation_api_url }}" method: POST body_format: json body: "{{ lookup('file', var_json_file) }}" return_content: yes headers: - Authorization: "{{ api_key }}" + Authorization: "{{ submitty_homework_creation_api_key }}" register: api_response - name: Fail when status is error From e31dc0953b97cca3a5e1f8830dc24e46d843ee80 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Fri, 25 Apr 2025 19:55:30 -0300 Subject: [PATCH 06/12] Remove git support --- .../playbooks/submitty_homework_creation.yml | 8 ------- .../submitty_homework_creation/tasks/main.yml | 22 ------------------- 2 files changed, 30 deletions(-) diff --git a/.setup/ansible/playbooks/submitty_homework_creation.yml b/.setup/ansible/playbooks/submitty_homework_creation.yml index 38408b9e111..86e03678c21 100644 --- a/.setup/ansible/playbooks/submitty_homework_creation.yml +++ b/.setup/ansible/playbooks/submitty_homework_creation.yml @@ -8,11 +8,6 @@ - name: Create gradeable ansible.builtin.include_role: name: submitty_homework_creation - - name: Create gradeable - ansible.builtin.include_role: - name: submitty_homework_creation - vars: - vcs: https://github.com/IDzyre/Tutorial.git # This is a fork of the Submitty tutorial repository with an added folder for the config files, I will ask on Monday if I could/should put it in the actual tutorial repository. vars_prompt: - name: submitty_homework_creation_api_url @@ -21,6 +16,3 @@ - name: submitty_homework_creation_passed_api_key prompt: Enter your API key private: yes - - name: submitty_homework_creation_vcs - prompt: Enter clone URL for Git repository if you are using one - private: no diff --git a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml index bb2152612b4..4cfdfaa02bd 100644 --- a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml +++ b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml @@ -1,28 +1,6 @@ -- name: Checkout repository containing config files - ansible.builtin.git: - repo: "{{ vcs }}" - dest: /tmp/Submitty - force: yes - update: yes - version: "main" - when: vcs != '' - -- name: Find files in the directory - ansible.builtin.find: - paths: "/tmp/Submitty/config_files/" # Replace with your directory path - file_type: file # Ensure you're finding files (not directories) - register: json_files - when: vcs != '' - -- name: Set a variable with the list of file paths - ansible.builtin.set_fact: - var_json_list: "{{ json_files.files | map(attribute='path') | list }}" - when: vcs != '' - - name: Read JSON content from a file ansible.builtin.set_fact: var_json_list: "{{ lookup('file', 'json_list.txt') | split('\n') }}" - when: vcs == '' - name: Use task list to loop through gradeables ansible.builtin.include_tasks: From fdae65e2e15e6ec7f3b416c523f5f9d6441d6de2 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Fri, 25 Apr 2025 20:05:51 -0300 Subject: [PATCH 07/12] Fix linting --- .setup/ansible/playbooks/submitty_homework_creation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.setup/ansible/playbooks/submitty_homework_creation.yml b/.setup/ansible/playbooks/submitty_homework_creation.yml index 86e03678c21..95738afd859 100644 --- a/.setup/ansible/playbooks/submitty_homework_creation.yml +++ b/.setup/ansible/playbooks/submitty_homework_creation.yml @@ -6,7 +6,7 @@ tasks: # This role is defined in the Submitty Repo under .setup/ansible/roles - name: Create gradeable - ansible.builtin.include_role: + ansible.builtin.include_role: name: submitty_homework_creation vars_prompt: From 8caa9073426b30bf683e705b95df1cbef85ef860 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 27 May 2025 22:21:51 -0300 Subject: [PATCH 08/12] Change json list file formatting --- .../roles/submitty_homework_creation/files/json_list.txt | 2 +- .setup/ansible/roles/submitty_homework_creation/tasks/main.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.setup/ansible/roles/submitty_homework_creation/files/json_list.txt b/.setup/ansible/roles/submitty_homework_creation/files/json_list.txt index b22ba4b175c..c2da9456261 100644 --- a/.setup/ansible/roles/submitty_homework_creation/files/json_list.txt +++ b/.setup/ansible/roles/submitty_homework_creation/files/json_list.txt @@ -1 +1 @@ -config_files/file_homework.json \ No newline at end of file +file_homework.json \ No newline at end of file diff --git a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml index 4cfdfaa02bd..3c1ce9adfa7 100644 --- a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml +++ b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml @@ -1,6 +1,6 @@ - name: Read JSON content from a file ansible.builtin.set_fact: - var_json_list: "{{ lookup('file', 'json_list.txt') | split('\n') }}" + var_json_list: "config_files/{{ lookup('file', 'json_list.txt') | split('\n') }}" - name: Use task list to loop through gradeables ansible.builtin.include_tasks: From a57a86dbc2be89457a5113b589d07c9da4070571 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 10 Jun 2025 10:23:02 -0800 Subject: [PATCH 09/12] testing get api key --- .github/workflows/api_key.yml | 26 +++++++++++++++++++ .github/workflows/ci.yml | 9 ++++++- .../Cypress-Ansible/ansible-course.spec.js | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/api_key.yml diff --git a/.github/workflows/api_key.yml b/.github/workflows/api_key.yml new file mode 100644 index 00000000000..3772444e392 --- /dev/null +++ b/.github/workflows/api_key.yml @@ -0,0 +1,26 @@ +name: Fetch API Key with Auth + +on: [push, workflow_dispatch] + +jobs: + fetch_key_and_run: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Fetch API key with basic auth + id: get_key + run: | + echo "Fetching API key with basic auth..." + API_KEY=$(curl -s -u instructor:instructor http://localhost:1511/api/key) + echo "API_KEY=$API_KEY" + echo "api_key=$API_KEY" >> "$GITHUB_OUTPUT" + + - name: Use the API key + env: + API_KEY: ${{ steps.get_key.outputs.api_key }} + run: | + echo "Using API key: $API_KEY" + # Place your logic here that uses $API_KEY diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d86d2fc4c32..91840ae97d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -926,12 +926,19 @@ jobs: ssh -T localhost sudo systemctl start postgresql - - name: Run ansible script + - name: Get API key shell: bash run: | + echo "x" + + - name: Run ansible scripts + shell: bash + run: | + SEMESTER=$(python3 -c 'from datetime import datetime; today = datetime.today(); semester = ("s" if today.month < 7 else "f") + str(today.year)[-2:]; print(semester)') cd .setup/ansible ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner submitty_install_submitty_version=${{ github.sha }} submitty_install_github_url=https://github.com/${{ github.repository }}.git' -i inventory/submitty playbooks/submitty_install.yml ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_course_creation.yml + ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_homework_creation.yml -e "localhost/api/${SEMESTER}/course/upload" - name: Set perms shell: bash diff --git a/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js b/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js index 9b40263e7f7..93403fcfc02 100644 --- a/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js +++ b/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js @@ -1,6 +1,6 @@ describe('Testing website when created by ansible scripts', () => { it('Should be able to login and see the course', () => { cy.login('instructor'); - cy.visit('term', 'course'); + cy.visit('term/course'); }); }); From 475d2516734b6571e68d764c15621dcfb3d09eb4 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 10 Jun 2025 10:24:57 -0800 Subject: [PATCH 10/12] testing get api key --- .github/workflows/api_key.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/api_key.yml b/.github/workflows/api_key.yml index 3772444e392..1804bfe74dc 100644 --- a/.github/workflows/api_key.yml +++ b/.github/workflows/api_key.yml @@ -14,6 +14,7 @@ jobs: id: get_key run: | echo "Fetching API key with basic auth..." + curl -s http://localhost:1511/api/key API_KEY=$(curl -s -u instructor:instructor http://localhost:1511/api/key) echo "API_KEY=$API_KEY" echo "api_key=$API_KEY" >> "$GITHUB_OUTPUT" From 591c612712f0d266effe67dde8a0e0340c5db57a Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 10 Jun 2025 10:37:25 -0800 Subject: [PATCH 11/12] testing get api key --- .github/workflows/api_key.yml | 27 --------------------------- .github/workflows/ci.yml | 16 ++++++++++------ site/cypress/support/utils.js | 1 + 3 files changed, 11 insertions(+), 33 deletions(-) delete mode 100644 .github/workflows/api_key.yml diff --git a/.github/workflows/api_key.yml b/.github/workflows/api_key.yml deleted file mode 100644 index 1804bfe74dc..00000000000 --- a/.github/workflows/api_key.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Fetch API Key with Auth - -on: [push, workflow_dispatch] - -jobs: - fetch_key_and_run: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Fetch API key with basic auth - id: get_key - run: | - echo "Fetching API key with basic auth..." - curl -s http://localhost:1511/api/key - API_KEY=$(curl -s -u instructor:instructor http://localhost:1511/api/key) - echo "API_KEY=$API_KEY" - echo "api_key=$API_KEY" >> "$GITHUB_OUTPUT" - - - name: Use the API key - env: - API_KEY: ${{ steps.get_key.outputs.api_key }} - run: | - echo "Using API key: $API_KEY" - # Place your logic here that uses $API_KEY diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 91840ae97d4..0f5b449b5c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -926,11 +926,6 @@ jobs: ssh -T localhost sudo systemctl start postgresql - - name: Get API key - shell: bash - run: | - echo "x" - - name: Run ansible scripts shell: bash run: | @@ -938,7 +933,16 @@ jobs: cd .setup/ansible ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner submitty_install_submitty_version=${{ github.sha }} submitty_install_github_url=https://github.com/${{ github.repository }}.git' -i inventory/submitty playbooks/submitty_install.yml ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_course_creation.yml - ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_homework_creation.yml -e "localhost/api/${SEMESTER}/course/upload" + + - name: Get API key + shell: bash + run: | + API_KEY=(curl -s -X POST http://localhost:1511/api/token -H "Content-Type: application/x-www-form-urlencoded" -d "user_id=instructor&password=instructor" | grep -oP '"token"\s*:\s*"\K[^"]+') + + - name: Create Homework + shell: bash + run: + ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_homework_creation.yml -e "localhost/api/${SEMESTER}/course/upload" -e "${API_KEY}"" - name: Set perms shell: bash diff --git a/site/cypress/support/utils.js b/site/cypress/support/utils.js index 1e1298cee9c..a82aa2a315a 100644 --- a/site/cypress/support/utils.js +++ b/site/cypress/support/utils.js @@ -43,6 +43,7 @@ export function getApiKey(user_id, password) { }).then((response) => { return response.body.data.token; }); + } /** From 737683878875c384f21d28abcbf9f6026c07c5d4 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Thu, 12 Jun 2025 09:49:21 -0800 Subject: [PATCH 12/12] Testing api again --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f5b449b5c2..175bf2522e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -937,12 +937,12 @@ jobs: - name: Get API key shell: bash run: | - API_KEY=(curl -s -X POST http://localhost:1511/api/token -H "Content-Type: application/x-www-form-urlencoded" -d "user_id=instructor&password=instructor" | grep -oP '"token"\s*:\s*"\K[^"]+') + echo 'RESPONSE=(curl -s -X POST http://localhost:1511/api/token -H "Content-Type: application/x-www-form-urlencoded" -d "user_id=instructor&password=instructor")' >> $GITHUB_ENV' - name: Create Homework shell: bash run: - ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_homework_creation.yml -e "localhost/api/${SEMESTER}/course/upload" -e "${API_KEY}"" + ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_homework_creation.yml -e "localhost/api/${SEMESTER}/course/upload" -e "${{ fromJson(env.RESPONSE).token }}" - name: Set perms shell: bash