Skip to content

Commit

Permalink
[Refactor:Developer] Refactor Repo (#39)
Browse files Browse the repository at this point in the history
This PR refactor's the whole repo to use the new github action for
building and pushing Docker images.

This adds a new CI test to only build the changed dockerfiles for PRs to
this repo. This is done in this PR to test the building for current
dockerfiles before merging.

Closes Submitty/Submitty#10461.
  • Loading branch information
cjreed121 authored Jul 16, 2024
1 parent 79d9dd6 commit 2a44936
Show file tree
Hide file tree
Showing 33 changed files with 57 additions and 295 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/docker-build-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Docker Build and Push

on:
pull_request:
branches:
- main

jobs:
call-docker-build-push:
uses: submitty/action-docker-build/.github/workflows/[email protected]
with:
push: false
docker_org_name: ${{ vars.docker_org_name }}
base_commit: ${{ github.event.pull_request.base.sha }}
head_commit: ${{ github.event.pull_request.head.sha }}
104 changes: 10 additions & 94 deletions .github/workflows/docker-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,97 +6,13 @@ on:
- "main"

jobs:
generate-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
run_docker_jobs: ${{ steps.set-run-docker-jobs.outputs.run_docker_jobs }}
run_latest_docker_jobs: ${{ steps.set-run-docker-jobs.outputs.run_latest_docker_jobs }}
latest-matrix: ${{ steps.set-matrix.outputs.latest-matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
- name: Get changed files
id: changed-files
run: |
echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
- name: Count number of files changed
id: set-run-docker-jobs
run: |
number_of_changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -E '^.*\/submitty\/[^/]+\/[^/]+\/Dockerfile$' | wc -l)
echo $number_of_changed_files
if [[ "$number_of_changed_files" -gt 0 ]]; then
echo "run_docker_jobs=true" >> $GITHUB_OUTPUT
else
echo "run_docker_jobs=false" >> $GITHUB_OUTPUT
fi
number_of_changed_latest_files=$(bash ./bin/check_docker_latest_run.sh ${{ github.event.before }} ${{ github.event.after }} | xargs )
echo $number_of_changed_latest_files
if [[ "$number_of_changed_latest_files" -gt 0 ]]; then
echo "run_latest_docker_jobs=true" >> $GITHUB_OUTPUT
else
echo "run_latest_docker_jobs=false" >> $GITHUB_OUTPUT
fi
- name: List changed files
run: |
for file in ${{ steps.changed-files.outputs.changed_files }}; do
echo "$file was changed"
done
- name: Set Matrix
id: set-matrix
run: |
echo "matrix=$(bash ./bin/generate_matrix.sh ${{ github.event.before }} ${{ github.event.after }} | xargs )" >> $GITHUB_OUTPUT
echo "latest-matrix=$(bash ./bin/generate_latest_matrix.sh ${{ github.event.before }} ${{ github.event.after }} | xargs )" >> $GITHUB_OUTPUT
- name: List Matrix
run: |
echo ${{ steps.set-matrix.outputs.matrix }}
echo ${{ steps.set-run-docker-jobs.outputs.run_docker_jobs }}
echo ${{ steps.set-matrix.outputs.latest-matrix }}
echo ${{ steps.set-run-docker-jobs.outputs.run_latest_docker_jobs }}
docker:
needs:
- generate-matrix
if: needs.generate-matrix.outputs.run_docker_jobs == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Check out repo
uses: actions/checkout@v3
- name: Docker Hub login
uses: docker/login-action@releases/v1
with:
username: ${{ secrets.DOCKER_USERNAME_SUBMITTY }}
password: ${{ secrets.DOCKER_PASSWORD_SUBMITTY }}
- name: Build and push docker
uses: docker/build-push-action@v4
with:
context: ${{ matrix.context }}
push: true
tags: submitty/${{ matrix.dockername }}:${{ matrix.tag }}
docker-latest:
needs:
- generate-matrix
if: needs.generate-matrix.outputs.run_latest_docker_jobs == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix: ${{ fromJson(needs.generate-matrix.outputs.latest-matrix) }}
steps:
- name: Check out repo
uses: actions/checkout@v3
- name: Docker Hub login
uses: docker/login-action@releases/v1
with:
username: ${{ secrets.DOCKER_USERNAME_SUBMITTY }}
password: ${{ secrets.DOCKER_PASSWORD_SUBMITTY }}
- name: Build and push docker
uses: docker/build-push-action@v4
with:
context: ${{ matrix.context }}
push: true
tags: submitty/${{ matrix.dockername }}:latest
call-docker-build-push:
uses: submitty/action-docker-build/.github/workflows/[email protected]
with:
push: true
docker_org_name: ${{ vars.docker_org_name }}
base_commit: ${{ github.event.before }}
head_commit: ${{ github.event.after }}
secrets:
docker_username: ${{ secrets.docker_username }}
docker_password: ${{ secrets.docker_password }}
48 changes: 0 additions & 48 deletions bin/check_docker_latest_run.sh

This file was deleted.

52 changes: 0 additions & 52 deletions bin/generate_latest_matrix.sh

This file was deleted.

27 changes: 0 additions & 27 deletions bin/generate_matrix.sh

This file was deleted.

4 changes: 4 additions & 0 deletions dockerfiles/autograding-default/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"pushLatest": true,
"latestTag": "ubuntu-20.04"
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ ENV AnalysisTools_Version v22.03.00
ENV AnalysisToolsTS_Version v23.06.01
ENV SUBMITTY_INSTALL_DIR /usr/local/submitty




RUN apt-get update \
&& apt-get install -y --no-install-recommends wget ca-certificates rsync \
&& mkdir -p ${SUBMITTY_INSTALL_DIR}/drmemory \
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions dockerfiles/clang/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"pushLatest": true,
"latestTag": "10"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN apt-get update && \
RUN curl -L -o /adoptopenjdk.tar.gz https://github.com/AdoptOpenJDK/openjdk11-upstream-binaries/releases/download/jdk-11.0.12%2B7/OpenJDK11U-jdk_x64_linux_11.0.12_7.tar.gz && \
tar -xzf /adoptopenjdk.tar.gz -C /opt && \
rm /adoptopenjdk.tar.gz && \
ln -s /opt/openjdk-11.0.12_7 /opt/openjdk11
ln -s /opt/jdk-11.0.12+7 /opt/openjdk11

# Set environment variables
ENV JAVA_HOME=/opt/openjdk11
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions dockerfiles/java/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"pushLatest": true,
"latestTag": "11"
}
File renamed without changes.
4 changes: 4 additions & 0 deletions dockerfiles/php/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"pushLatest": true,
"latestTag": "7.3-cli"
}
File renamed without changes.
4 changes: 4 additions & 0 deletions dockerfiles/python/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"pushLatest": true,
"latestTag": "3.7"
}
File renamed without changes.
3 changes: 3 additions & 0 deletions dockerfiles/tutorial/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"pushLatest": false
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN apt-get update \
&& rm -rf "/var/lib/apt/lists/*"

RUN apt-get update \
&& apt-get install -y iverilog gtkwave \
&& rm -rf "/var/lib/apt/lists/*"
&& apt-get install -y iverilog gtkwave \
&& rm -rf "/var/lib/apt/lists/*"

CMD ["/bin/bash"]
3 changes: 3 additions & 0 deletions dockerfiles/verilog/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"pushLatest": false
}
25 changes: 0 additions & 25 deletions latest.json

This file was deleted.

46 changes: 0 additions & 46 deletions test_images.py

This file was deleted.

0 comments on commit 2a44936

Please sign in to comment.