Skip to content

Commit 97e00ec

Browse files
Adding the basic testing (#22)
* adding the python script and github action for validation also adding the fix for tuple error in update_assignment_problems * chagning the checkout to v4 * fixing the comments * adding slack comment * fixing python version * Fixed pycodestyle errors detected by the linter * Automatic fix with linter * More linter fixes * Update CI environment variables for consistency * Revert "Update CI environment variables for consistency" This reverts commit 073b8a4. * fixing the ci flag for OMEGAUPUSER --------- Co-authored-by: Juan Pablo Gomez <gomez_aguilar_juan_pablo@hotmail.com>
1 parent 800a6a3 commit 97e00ec

19 files changed

Lines changed: 699 additions & 240 deletions

.github/workflows/continuous-integration.yaml

Lines changed: 168 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -11,121 +11,178 @@ env:
1111
OMEGAUPUSER: ${{ secrets.OMEGAUPUSER }}
1212
OMEGAUP_API_TOKEN: ${{ secrets.OMEGAUP_API_TOKEN }}
1313
GIT_USERNAME: ${{ github.actor }}
14+
GIT_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
15+
FIX_COMMIT_MESSAGE: Fixed /hook_tools/lint.py lints
1416

1517
jobs:
1618
build-test-deploy:
1719
if: github.event_name != 'pull_request' || github.event.pull_request.head.ref != 'sync-course'
1820
runs-on: ubuntu-22.04
1921
steps:
20-
- name: Checkout code
21-
uses: actions/checkout@v4
22-
with:
23-
fetch-depth: 0
24-
25-
- name: Cancel if merged from sync-course
26-
if: github.ref == 'refs/heads/main'
27-
run: |
28-
if git log -1 --merges --pretty=%B | grep -q 'sync-course'; then
29-
echo "Merged from sync-course. Skipping workflow."
30-
exit 0
31-
fi
32-
33-
- name: Set base commit (pull request)
34-
run: |
35-
echo "GITHUB_BASE_COMMIT=${{ github.event.pull_request.base.sha }}" >> $GITHUB_ENV
36-
echo "GITHUB_CURRENT_COMMIT=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
37-
if: github.ref != 'refs/heads/main'
38-
39-
- name: Set base commit (main)
40-
run: |
41-
echo "GITHUB_BASE_COMMIT=${{ github.event.before }}" >> $GITHUB_ENV
42-
echo "GITHUB_CURRENT_COMMIT=${{ github.event.after }}" >> $GITHUB_ENV
43-
if: github.ref == 'refs/heads/main'
44-
45-
- name: Set up environment
46-
run: |
47-
git config --global core.quotePath false
48-
echo "PIPENV_PIPFILE=$(pwd)/utils/Pipfile" >> $GITHUB_ENV
49-
- name: Set up Python
50-
uses: actions/setup-python@v5
51-
with:
52-
python-version: '3.8'
53-
54-
- uses: actions/checkout@v4
55-
with:
56-
ref: ${{ env.GITHUB_CURRENT_COMMIT }}
57-
fetch-depth: 0
58-
submodules: true
59-
60-
- name: Install Python dependencies
61-
run: |
62-
python -m pip install --upgrade pip
63-
(cd utils && sudo pip install pipenv==2023.11.15 && pipenv install)
64-
- name: Set up the CI flags.
65-
run: |
66-
# When the utils/ directory is changed, run all tests to avoid
67-
# regressions. Exit status of 0 means "unmodified".
68-
if git diff-tree --quiet ${{ env.GITHUB_BASE_COMMIT }} ${{ env.GITHUB_CURRENT_COMMIT }} -- utils/; then
69-
echo "CI_FLAGS=--ci" >> $GITHUB_ENV
70-
else
71-
echo "CI_FLAGS=--ci --all" >> $GITHUB_ENV
72-
fi
73-
- name: Download omegaUp-ci container
74-
run: |
75-
docker login https://docker.pkg.github.com -u ${{ github.actor }} -p ${{ github.token }}
76-
python3 ./utils/runtests.py ${{ env.CI_FLAGS }} --only-pull-image
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Cancel if merged from sync-course
28+
if: github.ref == 'refs/heads/main'
29+
run: |
30+
if git log -1 --merges --pretty=%B | grep -q 'sync-course'; then
31+
echo "Merged from sync-course. Skipping workflow."
32+
exit 0
33+
fi
34+
35+
- name: Set base commit (pull request)
36+
run: |
37+
echo "GITHUB_BASE_COMMIT=${{ github.event.pull_request.base.sha }}" >> $GITHUB_ENV
38+
echo "GITHUB_CURRENT_COMMIT=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
39+
if: github.ref != 'refs/heads/main'
40+
41+
- name: Set base commit (main)
42+
run: |
43+
echo "GITHUB_BASE_COMMIT=${{ github.event.before }}" >> $GITHUB_ENV
44+
echo "GITHUB_CURRENT_COMMIT=${{ github.event.after }}" >> $GITHUB_ENV
45+
if: github.ref == 'refs/heads/main'
46+
47+
- name: Set up environment
48+
run: |
49+
git config --global core.quotePath false
50+
echo "PIPENV_PIPFILE=$(pwd)/utils/Pipfile" >> $GITHUB_ENV
51+
52+
- name: Set up Python
53+
uses: actions/setup-python@v5
54+
with:
55+
python-version: '3.8'
56+
57+
- uses: actions/checkout@v2
58+
with:
59+
ref: ${{ env.GITHUB_CURRENT_COMMIT }}
60+
fetch-depth: 0
61+
submodules: true
62+
63+
- name: Install Python dependencies
64+
run: |
65+
python -m pip install --upgrade pip
66+
(cd utils && sudo pip install pipenv==2023.11.15 && pipenv install)
67+
68+
- name: Set up the CI flags
69+
run: |
70+
if git diff-tree --quiet ${{ env.GITHUB_BASE_COMMIT }} ${{ env.GITHUB_CURRENT_COMMIT }} -- utils/; then
71+
echo "CI_FLAGS=--ci" >> $GITHUB_ENV
72+
else
73+
echo "CI_FLAGS=--ci --all" >> $GITHUB_ENV
74+
fi
75+
76+
- name: Download omegaUp-ci container
77+
run: |
78+
docker login https://docker.pkg.github.com -u ${{ github.actor }} -p ${{ github.token }}
79+
python3 ./utils/runtests.py ${{ env.CI_FLAGS }} --only-pull-image
80+
81+
# - name: Run tests
82+
# run: python3 ./utils/runtests.py ${{ env.CI_FLAGS }}
83+
84+
- name: Generate pngs/testplan
85+
run: python3 ./utils/generateresources.py --generate=png,testplan ${{ env.CI_FLAGS }}
86+
if: github.ref == 'refs/heads/main'
87+
88+
- name: Deploy to omegaUp
89+
run: pipenv run python3 ./utils/upload.py --ci --verbose
90+
if: github.ref == 'refs/heads/main'
91+
92+
- name: Push to public branch
93+
if: github.ref == 'refs/heads/main'
94+
run: |
95+
shopt -s extglob
96+
git config --global user.name "${{ env.GIT_USERNAME }}"
97+
git config --global user.email "${{ env.GIT_USERNAME }}@users.noreply.github.com"
98+
git add -f !(results)
99+
git commit --allow-empty -m "Generated files from $GITHUB_SHA"
100+
TMP_COMMIT=$(git rev-parse HEAD)
101+
git checkout public
102+
git merge --no-commit --no-ff -X theirs $TMP_COMMIT
103+
git commit --allow-empty -m "Auto deployed from $GITHUB_SHA"
104+
git push origin public
105+
106+
- name: Zip logs
107+
if: ${{ always() }}
108+
run: |
109+
if [[ -d results/ && "$(find results/ -type f)" != "" ]]; then
110+
(cd results && zip -r ../results.zip .)
111+
fi
112+
113+
- name: Upload logs
114+
if: ${{ always() }}
115+
uses: actions/upload-artifact@v4
116+
with:
117+
name: omegaUp-CI-logs
118+
path: results.zip
77119

78-
# - name: Run tests
79-
# run: python3 ./utils/runtests.py ${{ env.CI_FLAGS }}
80-
81-
- name: Generate pngs/testplan
82-
run: python3 ./utils/generateresources.py --generate=png,testplan ${{ env.CI_FLAGS }}
83-
if: github.ref == 'refs/heads/main'
84-
85-
- name: Deploy to omegaUp
86-
run: pipenv run python3 ./utils/upload.py --ci --verbose # Don't use CI_FLAGS to avoid deploying all problems.
87-
if: github.ref == 'refs/heads/main'
88-
89-
- name: Push to public branch
90-
if: github.ref == 'refs/heads/main'
91-
run: |
92-
shopt -s extglob
93-
git config --global user.name "${{ env.GIT_USERNAME }}"
94-
git config --global user.email "${{ env.GIT_USERNAME }}@users.noreply.github.com"
95-
git add -f !(results)
96-
git commit --allow-empty -m "Generated files from $GITHUB_SHA"
97-
TMP_COMMIT=$(git rev-parse HEAD)
98-
git checkout public
99-
git merge --no-commit --no-ff -X theirs $TMP_COMMIT
100-
git commit --allow-empty -m "Auto deployed from $GITHUB_SHA"
101-
git push origin public
102-
103-
- name: Zip logs
104-
if: ${{ always() }}
105-
run: |
106-
# actions/upload-artifacts action upload each and every log file
107-
# individually through one API call. This is extremely slow (~2
108-
# minutes) due to there being thousands of little files. Instead, .zip
109-
# them all by hand and let the upload action just upload the .zip. Yes,
110-
# this causes there to be a .zip within a .zip, but the billable
111-
# minutes savings are worth it.
112-
if [[ -d results/ && "$(find results/ -type f)" != "" ]]; then
113-
(cd results && zip -r ../results.zip .)
114-
fi
115-
116-
- name: Upload logs
117-
if: ${{ always() }}
118-
uses: actions/upload-artifact@v4
119-
with:
120-
name: omegaUp-CI-logs
121-
path: results.zip
122-
123-
# - name: Notify Slack on failure
124-
# uses: 8398a7/action-slack@v3
125-
# with:
126-
# status: ${{ job.status }}
127-
# fields: repo,message,commit,author,action,eventName,ref,workflow
128-
# env:
129-
# GITHUB_TOKEN: ${{ github.token }}
130-
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
131-
# if: ${{ failure() && github.ref == 'refs/heads/main' }}
120+
# - name: Notify Slack on failure
121+
# uses: 8398a7/action-slack@v3
122+
# with:
123+
# status: ${{ job.status }}
124+
# fields: repo,message,commit,author,action,eventName,ref,workflow
125+
# env:
126+
# GITHUB_TOKEN: ${{ github.token }}
127+
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
128+
# if: ${{ failure() && github.ref == 'refs/heads/main' }}
129+
130+
validate-content:
131+
runs-on: ubuntu-latest
132+
steps:
133+
- uses: actions/checkout@v4
134+
with:
135+
ref: ${{ github.head_ref }}
136+
fetch-depth: 0
137+
submodules: true
138+
139+
- name: Set base commit (pull request)
140+
run: |
141+
echo "GITHUB_BASE_COMMIT=${{ github.event.pull_request.base.sha }}" >> $GITHUB_ENV
142+
echo "GITHUB_CURRENT_COMMIT=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
143+
if: github.ref != 'refs/heads/main'
144+
145+
- name: Set base commit (main)
146+
run: |
147+
echo "GITHUB_BASE_COMMIT=${{ github.event.before }}" >> $GITHUB_ENV
148+
echo "GITHUB_CURRENT_COMMIT=${{ github.event.after }}" >> $GITHUB_ENV
149+
if: github.ref == 'refs/heads/main'
150+
151+
- name: Set up Python
152+
uses: actions/setup-python@v5
153+
with:
154+
python-version: '3.8'
155+
156+
- name: Validate content structure
157+
run: |
158+
cd utils
159+
python validate_content.py
160+
161+
lint:
162+
runs-on: ubuntu-latest
163+
steps:
164+
- uses: actions/checkout@v4
165+
with:
166+
ref: ${{ github.head_ref }}
167+
fetch-depth: 0
168+
submodules: true
169+
170+
- name: Pull container
171+
run: ./utils/lint --only-pull-image
172+
173+
- name: Validate lint
174+
run: |
175+
echo "Running lint validation..."
176+
if ! ./utils/lint \
177+
--command-name="utils/lint" \
178+
--diagnostics-output=github \
179+
validate --all; then
180+
echo "❌ Lint errors detected."
181+
echo "Please run the following locally to fix them:"
182+
echo ""
183+
echo " ./utils/lint fix --all"
184+
echo " git commit -am 'Fix lints'"
185+
echo " git push"
186+
echo ""
187+
exit 1
188+
fi

Courses/ResolviendoProblemas2021/SP1/Solucion-Tablero-de-Ajedrez/settings.distrib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
"name": "token",
1212
"tolerance": 1e-9
1313
}
14-
}
14+
}

Courses/ResolviendoProblemas2021/SP1/Solucion-Tablero-de-Ajedrez/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"Slow": false,
1111
"Validator": {
1212
"Name": "token",
13-
"Tolerance": 1e-09
13+
"Tolerance": 1e-9
1414
},
1515
"alias": "Solucion-Tablero-de-Ajedrez",
1616
"title": "Solucion-Tablero-de-Ajedrez"
17-
}
17+
}

Courses/ResolviendoProblemas2021/course_settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@
4141
"student_count": 3601,
4242
"status": "ok",
4343
"_id": "687fbf750b4fc467807147"
44-
}
44+
}

Courses/omi-public-course/course_settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@
4646
"student_count": 1,
4747
"status": "ok",
4848
"_id": "687fbf7ef02b3240940230"
49-
}
49+
}

Courses/omi-public-course/intro/demo-de-objetivo/settings.distrib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"group_score_policy": "sum-if-not-zero",
1313
"tolerance": 1e-9
1414
}
15-
}
15+
}

Courses/omi-public-course/intro/demo-de-objetivo/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"Slow": false,
1111
"Validator": {
1212
"Name": "token-caseless",
13-
"Tolerance": 1e-09,
13+
"Tolerance": 1e-9,
1414
"GroupScorePolicy": "sum-if-not-zero"
1515
},
1616
"alias": "demo-de-objetivo",
1717
"title": "demo-de-objetivo"
18-
}
18+
}

Courses/omi-public-course/practice/Contest-Start/settings.distrib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
"group_score_policy": "sum-if-not-zero",
1919
"tolerance": 1e-9
2020
}
21-
}
21+
}

Courses/omi-public-course/practice/Contest-Start/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
"Slow": false,
3333
"Validator": {
3434
"Name": "token-caseless",
35-
"Tolerance": 1e-09,
35+
"Tolerance": 1e-9,
3636
"GroupScorePolicy": "sum-if-not-zero"
3737
},
3838
"alias": "Contest-Start",
3939
"title": "Contest-Start"
40-
}
40+
}

Courses/omi-public-course/practice/New-Test-1/settings.distrib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
"group_score_policy": "sum-if-not-zero",
1919
"tolerance": 1e-9
2020
}
21-
}
21+
}

0 commit comments

Comments
 (0)