@@ -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
1517jobs :
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
0 commit comments