Skip to content

Commit

Permalink
Merge pull request #50 from MathieuSoysal/39-create-a-archive-file-th…
Browse files Browse the repository at this point in the history
…at-contains-all-logement

Road to v1.8.0
  • Loading branch information
MathieuSoysal authored Feb 6, 2024
2 parents 2ca7f9c + c842d8d commit 36f3697
Show file tree
Hide file tree
Showing 48 changed files with 1,027 additions and 224 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/Integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Integration Tests

on:
push:
branches: [ master, beta ]
pull_request:
branches: [ master, beta ]
workflow_call:

jobs:
unit-test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Build & Install
run: mvn -B install -D skipTests --no-transfer-progress
- name: Install Playwright
run: mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install --with-deps"
- name: Run tests
run: mvn test
env:
SPECIFIC_DAY: "2024-01-03"
ARCHIVE_MODE: HOUR
TEST_MAIL : ${{ secrets.TEST_MAIL }}
TEST_PASSWORD : ${{ secrets.TEST_PASSWORD }}

creating-archive-with-connection:
needs: unit-test
uses: ./.github/workflows/reusable-archiving.yml
with:
ARCHIVE_MODE: HOUR
secrets:
MAIL : ${{ secrets.TEST_MAIL }}
PASSWORD : ${{ secrets.TEST_PASSWORD }}

creating-archive-day-sum-up:
needs: unit-test
uses: ./.github/workflows/reusable-archiving.yml
with:
ARCHIVE_MODE: DAY_SUM_UP
SPECIFIC_DAY: "2024-01-03"
LINK_TO_DATA: https://mathieusoysal.github.io/CROUS-assistant-Collector/v1/logements-crous/available

creating-archive-all-logement:
needs: unit-test
uses: ./.github/workflows/reusable-archiving.yml
with:
ARCHIVE_MODE: ALL_LOGEMENTS
SPECIFIC_DAY: "2024-01-03"
LINK_TO_DATA: https://mathieusoysal.github.io/CROUS-assistant-Collector/v1/logements-crous/available
57 changes: 30 additions & 27 deletions .github/workflows/archiving-day.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
name: Archiving data
name: Archiving data for day summary

on:
schedule:
- cron: '40 23 * * *'
workflow_dispatch:
inputs:
specific-date:
description: 'Specific date to archive'
required: true
default: '2024-01-01'

jobs:
creating-archive:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'
- name: Install Playwright
run: mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install --with-deps"
- name: archive
run: |
(echo "===== Maven Deploy Attempt: 1 ====" && mvn install -DskipTests=true -Dmaven.javadoc.skip=true -PArchiving exec:java) || \
(echo "===== Maven Deploy Attempt: 2 ====" && mvn install -DskipTests=true -Dmaven.javadoc.skip=true -PArchiving exec:java) || \
(echo "===== Maven Deploy Attempt: 3 ====" && mvn install -DskipTests=true -Dmaven.javadoc.skip=true -PArchiving exec:java) || \
(echo "==== Maven Deploy Step Failed ====" && exit 1)
env:
LINK_TO_DATA: https://mathieusoysal.github.io/CROUS-assistant-Collector/v1/logements-crous/available
- uses: JamesIves/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
clean: false
branch: api
folder: archive
target-folder: v1/logements-crous/available
creating-archive-schedule:
permissions:
contents: write
if: github.event_name == 'schedule'
uses: ./.github/workflows/reusable-archiving.yml
with:
ARCHIVE_MODE: DAY_SUM_UP
LINK_TO_DATA: https://mathieusoysal.github.io/CROUS-assistant-Collector/v1/logements-crous/available
deploy: true
secrets:
token: ${{ secrets.GITHUB_TOKEN }}

creating-archive-manual:
permissions:
contents: write
if: github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/reusable-archiving.yml
with:
SPECIFIC_DAY: ${{ github.event.inputs.specific-date }}
ARCHIVE_MODE: DAY_SUM_UP
LINK_TO_DATA: https://mathieusoysal.github.io/CROUS-assistant-Collector/v1/logements-crous/available
deploy: true
secrets:
token: ${{ secrets.GITHUB_TOKEN }}



Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/archiving-hour.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Archiving data for hour

on:
schedule:
- cron: '10 * * * *'
workflow_dispatch:

jobs:
creating-archive:
permissions:
contents: write
uses: ./.github/workflows/reusable-archiving.yml
with:
ARCHIVE_MODE: HOUR
deploy: true
secrets:
MAIL : ${{ secrets.TEST_MAIL }}
PASSWORD : ${{ secrets.TEST_PASSWORD }}
token: ${{ secrets.GITHUB_TOKEN }}

rerun-failed-jobs:
runs-on: ubuntu-latest
needs: creating-archive
if: failure()
steps:
- name: Rerun failed jobs in the current workflow
env:
GH_TOKEN: ${{ github.token }}
run: gh run rerun ${{ github.run_id }} --failed





40 changes: 0 additions & 40 deletions .github/workflows/archiving.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/workflows/playwright.yml

This file was deleted.

9 changes: 8 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ on:
- created

jobs:

tests:
uses: ./.github/workflows/Integration-test.yml
secrets: inherit

build:
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
Expand Down Expand Up @@ -47,6 +53,7 @@ jobs:
- name: Build JIB container and publish to GitHub Packages
run: |
mvn package com.google.cloud.tools:jib-maven-plugin:3.3.2:build \
-Djib.from.image=mcr.microsoft.com/playwright/java:v1.41.0-jammy \
-Djib.to.image=ghcr.io/${{ steps.downcase.outputs.lowercase }}:latest \
-Djib.to.auth.username=${{ github.actor }} \
-Djib.to.auth.password=${{ secrets.GITHUB_TOKEN }} $MULTI_MODULE_ARGS $MAIN_CLASS_ARGS
Expand Down
76 changes: 76 additions & 0 deletions .github/workflows/reusable-archiving.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Archiving data with reusable workflow

on:
workflow_call:
inputs:
ARCHIVE_MODE:
description: 'The mode of archiving'
required: true
type: string
default: 'HOUR'
LINK_TO_DATA:
description: 'The link to the data to archive'
required: false
type: string
default: 'https://mathieusoysal.github.io/CROUS-assistant-Collector/v1/logements-crous/available'
SPECIFIC_DAY:
description: 'The day to archive, day is used olny if ARCHIVE_MODE is DAY'
required: false
type: string
default: ''
deploy:
description: 'Deploy the archive to github pages'
required: false
type: boolean
default: false
target-folder:
description: 'The target folder to deploy the archive to github pages'
required: false
type: string
default: 'v1/logements-crous'

secrets:
MAIL:
description: 'The mail to send the archive to hour, mail is used olny if ARCHIVE_MODE is HOUR'
PASSWORD:
description: 'The password of the mail to send the archive to hour, password is used olny if ARCHIVE_MODE is HOUR'
token:
description: 'The token to deploy the archive to github pages'

jobs:
creating-archive:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'
- name: Install Playwright
run: mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install --with-deps"

- name: set specific day when input is not empty
if: inputs.SPECIFIC_DAY != ''
run: echo "SPECIFIC_DAY=${{ inputs.SPECIFIC_DAY }}" >> $GITHUB_ENV

- name: archive
run: |
(echo "===== Maven Deploy Attempt: 1 ====" && mvn install -DskipTests=true -Dmaven.javadoc.skip=true -PArchiving exec:java) || \
(echo "===== Maven Deploy Attempt: 2 ====" && mvn install -DskipTests=true -Dmaven.javadoc.skip=true -PArchiving exec:java) || \
(echo "===== Maven Deploy Attempt: 3 ====" && mvn install -DskipTests=true -Dmaven.javadoc.skip=true -PArchiving exec:java) || \
(echo "==== Maven Deploy Step Failed ====" && exit 1)
env:
LINK_TO_DATA: ${{ inputs.LINK_TO_DATA }}
ARCHIVE_MODE: ${{ inputs.ARCHIVE_MODE }}
MAIL: ${{ secrets.MAIL }}
PASSWORD: ${{ secrets.PASSWORD }}
- name: Deploy to Github Pages
if: inputs.deploy == true
uses: JamesIves/[email protected]
with:
token: ${{ secrets.token }}
clean: false
branch: api
folder: archive
target-folder: ${{ inputs.target-folder }}
39 changes: 39 additions & 0 deletions .github/workflows/update-all-logements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Update all logements

on:
schedule:
- cron: '40 23 * * *'
workflow_dispatch:
inputs:
specific-date:
description: 'Specific date to archive'
required: true
default: '2024-01-01'

jobs:
creating-archive-schedule:
permissions:
contents: write
if: github.event_name == 'schedule'
uses: ./.github/workflows/reusable-archiving.yml
with:
ARCHIVE_MODE: ALL_LOGEMENTS
LINK_TO_DATA: https://mathieusoysal.github.io/CROUS-assistant-Collector/v1/logements-crous/available
target-folder: 'v1/logements-crous'
deploy: true
secrets:
token: ${{ secrets.GITHUB_TOKEN }}

creating-archive-manual:
permissions:
contents: write
if: github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/reusable-archiving.yml
with:
SPECIFIC_DAY: ${{ github.event.inputs.specific-date }}
ARCHIVE_MODE: ALL_LOGEMENTS
LINK_TO_DATA: https://mathieusoysal.github.io/CROUS-assistant-Collector/v1/logements-crous/available
target-folder: 'v1/logements-crous'
deploy: true
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit 36f3697

Please sign in to comment.