diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml deleted file mode 100644 index 9089797..0000000 --- a/.github/workflows/build-image.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: Build and push image on PR - -on: - pull_request: - branches: - - main - -jobs: - build-and-push: - runs-on: ubuntu-latest - steps: - - name: cleanup disk space - run: | - sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc - df -h - - - name: Checkout files in repo - uses: actions/checkout@main - - - name: Set up QEMU (for docker buildx) - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx (for chartpress multi-arch builds) - uses: docker/setup-buildx-action@v3 - - - name: Setup push rights to Quay.io - run: | - docker login -u "${{ secrets.QUAY_USERNAME }}" -p "${{ secrets.QUAY_PASSWORD }}" quay.io - - - name: Build the image and push to quay.io if not a pull request - uses: jupyterhub/repo2docker-action@master - with: - DOCKER_USERNAME: ${{ secrets.QUAY_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.QUAY_PASSWORD }} - DOCKER_REGISTRY: "quay.io" - LATEST_TAG_OFF: true - IMAGE_NAME: "2i2c-org/frx-challenges" - - - name: Show how much disk space is left - run: df -h diff --git a/.github/workflows/publish-chart.yaml b/.github/workflows/publish-chart.yaml index a371a3f..78d38ed 100644 --- a/.github/workflows/publish-chart.yaml +++ b/.github/workflows/publish-chart.yaml @@ -41,29 +41,7 @@ jobs: - uses: actions/setup-python@v5 with: - python-version: "3.11" - - - name: Decide to publish or not - id: publishing - shell: python - run: | - import os - repo = "${{ github.repository }}" - event = "${{ github.event_name }}" - ref = "${{ github.event.ref }}" - publishing = "" - if ( - repo == "2i2c-org/frx-challenges" - and event == "push" - and ( - ref.startswith("refs/tags/") - or ref == "refs/heads/main" - ) - ): - publishing = "true" - print("Publishing chart") - with open(os.environ["GITHUB_OUTPUT"], "a") as f: - f.write(f"publishing={publishing}\n") + python-version: "3.12" - name: Set up QEMU (for docker buildx) uses: docker/setup-qemu-action@v3 @@ -71,10 +49,12 @@ jobs: - name: Set up Docker Buildx (for chartpress multi-arch builds) uses: docker/setup-buildx-action@v3 - - name: Setup push rights to Quay.io - if: steps.publishing.outputs.publishing - run: | - docker login -u "${{ secrets.QUAY_USERNAME }}" -p "${{ secrets.QUAY_PASSWORD }}" quay.io + - name: Login to Quay.io + uses: docker/login-action@v3 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_PASSWORD }} - name: Set up push rights to frx-challenges-helm-chart # This was setup by... @@ -86,7 +66,6 @@ jobs: # 3. Registering the public key (gh-pages.pub) as a deploy key # with push rights for the 2i2c-org/frx-challenges-helm-chart repo: # https://github.com/2i2c-org/frx-challenges-helm-chart/settings/keys - if: steps.publishing.outputs.publishing run: | mkdir -p ~/.ssh ssh-keyscan github.com >> ~/.ssh/known_hosts @@ -104,21 +83,13 @@ jobs: git config --global user.email "github-actions@github.com" git config --global user.name "github-actions" - - name: Build image, push if necessary - env: - PUBLISHING: ${{ steps.publishing.outputs.publishing }} + - name: Build image and push run: | - CHARTPRESS_ARGS="" - if [[ "${PUBLISHING}" == "true" ]]; then - CHARTPRESS_ARGS="--push" - fi chartpress \ --builder docker-buildx \ - --platform linux/amd64 --platform linux/arm64 \ - ${CHARTPRESS_ARGS} + --platform linux/amd64 --platform linux/arm64 - name: Publish chart with chartpress - if: steps.publishing.outputs.publishing run: | set -eux diff --git a/.gitignore b/.gitignore index 23ff20a..5f88199 100644 --- a/.gitignore +++ b/.gitignore @@ -163,3 +163,7 @@ cython_debug/ # MyST _build + +# VS Code +.DS_Store +.vscode/ diff --git a/frx_challenges/web/templates/version.html b/frx_challenges/web/templates/version.html index 211cbd6..63e7788 100644 --- a/frx_challenges/web/templates/version.html +++ b/frx_challenges/web/templates/version.html @@ -8,19 +8,26 @@

- Status: {{ evaluation.status }} + Status: {% if evaluation.status != "EVALUATED" and evaluation.status != "FAILED" %} + {{ evaluation.status }} Check for updates + {% else %} + {{ evaluation.status }} {% endif %}
- {{ version.user.username }} uploaded {{ version.filename }} {{ version.created_at|timesince }} ago + {{ version.user.username }} uploaded {{ version.filename }} {{ version.created_at|timesince }} + ago

Result

+ {% if is_collaborator and evaluation.status == 'EVALUATED' %} + Download results + {% endif %} {% if evaluation.status == 'EVALUATED' %} {% for result_item in results_display %}
diff --git a/frx_challenges/web/urls.py b/frx_challenges/web/urls.py index 9a9bc4d..b1c31be 100644 --- a/frx_challenges/web/urls.py +++ b/frx_challenges/web/urls.py @@ -4,6 +4,9 @@ urlpatterns = [ path("upload/", versions.upload, name="upload"), + path( + "download-results/", versions.download_results, name="download-results" + ), path("page/", pages.view, name="page-view"), path("file/", pages.content_file, name="content-file"), path("leaderboard", default.leaderboard, name="leaderboard"), diff --git a/frx_challenges/web/views/versions.py b/frx_challenges/web/views/versions.py index f8229d2..b056f09 100644 --- a/frx_challenges/web/views/versions.py +++ b/frx_challenges/web/views/versions.py @@ -1,3 +1,4 @@ +import json import os import tempfile @@ -51,9 +52,32 @@ def upload(request: HttpRequest, id: int) -> HttpResponse: ) +@login_required +def download_results(request: HttpRequest, id: int) -> HttpResponse: + version = Version.objects.get(id=id) + is_collaborator = _validate_collaborator(request, id) + if not is_collaborator: + raise Http404( + "Full results files are only available to submission collaborators." + ) + evaluation = version.latest_evaluation + if not evaluation.result: + raise Http404("No results available for this version.") + + # Create a JSON response from the evaluation results + response = HttpResponse( + content_type="application/json", + ) + response["Content-Disposition"] = f'attachment; filename="results_{id}.json"' + + response.write(json.dumps(evaluation.result, indent=4)) + return response + + def view(request: HttpRequest, id: int) -> HttpResponse: version = Version.objects.get(id=id) evaluation = version.latest_evaluation + is_collaborator = _validate_collaborator(request, id) results_display = [] if evaluation.result: @@ -72,6 +96,7 @@ def view(request: HttpRequest, id: int) -> HttpResponse: "version": version, "evaluation": evaluation, "results_display": results_display, + "is_collaborator": is_collaborator, }, )