# .gitlab-ci.yml -- Pamhyr gitlab-ci # Copyright (C) 2023-2024 INRAE # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . stages: - downloads - configure - test - build - package - hash - antivirus - release ############# # DOWNLOADS # ############# variables: MAGE_8_VERSION: "v8.3.5" dl-mage8-doc: stage: downloads tags: - linux rules: - if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG script: - mkdir -p doc - cd doc - curl -L -o mage8.pdf https://gitlab.irstea.fr/jean-baptiste.faure/mage/-/releases/$MAGE_8_VERSION/downloads/documents/Mage-8_Documentation.pdf artifacts: paths: - doc/mage8.pdf dl-mage8-linux: stage: downloads tags: - linux rules: - if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG script: - curl -L -o mage8.tgz https://gitlab.irstea.fr/jean-baptiste.faure/mage/-/releases/$MAGE_8_VERSION/downloads/packages/mage_linux.tgz - mkdir -p mage8-linux - cd mage8-linux - tar xvf ../mage8.tgz artifacts: paths: - mage8-linux/mage - mage8-linux/mage_as7 - mage8-linux/mage_extraire - mage8-linux/mailleurTT - mage8-linux/libbief.so dl-mage8-windows: stage: downloads tags: - linux rules: - if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG script: - curl -L -o mage8.tgz https://gitlab.irstea.fr/jean-baptiste.faure/mage/-/releases/$MAGE_8_VERSION/downloads/packages/mage_windows.tgz - mkdir -p mage8-windows - cd mage8-windows - tar xvf ../mage8.tgz artifacts: paths: - mage8-windows/mage.exe - mage8-windows/mage_as7.exe - mage8-windows/mage_extraire.exe - mage8-windows/mailleurTT.exe - mage8-windows/libbief.dll ############# # CONFIGURE # ############# set-version: stage: configure tags: - linux script: - cd packages - ./version.sh "$CI_COMMIT_BRANCH" "$CI_COMMIT_TAG" "$CI_COMMIT_SHORT_SHA" artifacts: paths: - VERSION build-lang: stage: configure tags: - linux script: - cd ./src/lang/ - ./create_ts.sh artifacts: paths: - src/lang/*.qm ######### # TESTS # ######### unittest: stage: test tags: - linux needs: - job: set-version artifacts: true script: - python3 -m venv venv - . venv/bin/activate - pip3 install -U pip - pip3 install -r ./full-requirements.txt - pip3 install -U -r ./full-requirements.txt - cd src - python3 -m unittest discover -t . test-pep8: stage: test tags: - linux needs: - job: set-version artifacts: true - job: unittest script: # Setup virtual env - python3 -m venv venv - . venv/bin/activate - pip3 install -U pip - pip3 install -r ./requirements.txt - pip3 install -U -r ./requirements.txt - pip3 install pycodestyle - pycodestyle --exclude="*_to_*.py" ./src allow_failure: true ######### # BUILD # ######### # build-users-doc: # stage: build # tags: # - linux # needs: # - job: set-version # artifacts: true # script: # - cd ./doc/users/ # - ./build.sh # artifacts: # paths: # - doc/users/documentation.pdf # - doc/users/documentation.html # - doc/users/images/ # allow_failure: true build-td: stage: build tags: - linux needs: - job: set-version artifacts: true script: - cd ./doc/users/Tuto1/ - ./build.sh artifacts: paths: - doc/users/Tuto1/step-by-step.pdf - doc/users/Tuto1/pas-a-pas.pdf - doc/users/Tuto1/data/ allow_failure: true build-developers-doc: stage: build tags: - linux needs: - job: set-version artifacts: true script: - cd ./doc/dev/ - ./build.sh # Create html documentation - cd ../../src - python3 -m venv doc-venv - . doc-venv/bin/activate - pip3 install -U pip - pip3 install -r ../full-requirements.txt - pip3 install -U -r ../full-requirements.txt - pip3 install pdoc3 - pdoc --html . # Create archive - tar cf html.tar ./html - cd ../doc/dev - mv ../../src/html.tar ./ artifacts: paths: - doc/dev/documentation.pdf - doc/dev/documentation.html - doc/dev/html.tar - doc/dev/images/ allow_failure: true build-linux: stage: build tags: - linux rules: - if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG needs: - job: dl-mage8-linux artifacts: true - job: dl-mage8-doc artifacts: true - job: set-version artifacts: true - job: build-lang artifacts: true - job: build-developers-doc artifacts: true # - job: build-users-doc # artifacts: true - job: build-td artifacts: true script: - mkdir -p linux - cd linux # Setup virtual env - python3 -m venv linux-venv - . linux-venv/bin/activate - pip3 install -U pip - pip3 install -r ../requirements.txt - pip3 install -U -r ../requirements.txt # Run Pyinstaller - pyinstaller -y --paths linux-venv/lib/python3.8/site-packages ../src/pamhyr.py # Create directory - mkdir -p pamhyr - mkdir -p pamhyr/_internal # Copy Pamhyr info - cp -v ../VERSION pamhyr/_internal/ - cp -v ../AUTHORS pamhyr/_internal/ - cp -v ../LICENSE pamhyr/_internal/ - cp -v ../src/motd.txt pamhyr/_internal/ # Copy mage - mkdir -p pamhyr/mage8 - cp -v ../mage8-linux/* pamhyr/mage8/ # Copy Pamhyr - cp -r dist/pamhyr/* pamhyr/ # Copy Pamhyr resources - mkdir -p pamhyr/_internal/View - mkdir -p pamhyr/_internal/View/ui - mkdir -p pamhyr/_internal/View/ui/Widgets - cp -r ../src/View/ui/*.ui pamhyr/_internal/View/ui/ - cp -r ../src/View/ui/ressources/ pamhyr/_internal/View/ui - cp -r ../src/View/ui/Widgets/*.ui pamhyr/_internal/View/ui/Widgets # Copy lang - mkdir -p pamhyr/_internal/lang - cp -r ../src/lang/*.qm pamhyr/_internal/lang # Copy tests cases - mkdir -p pamhyr/tests_cases/ - mkdir -p pamhyr/tests_cases/Saar - cp ../tests_cases/Saar/Saar.pamhyr pamhyr/tests_cases/Saar/ # Copy documentations - mkdir -p pamhyr/doc/ - mkdir -p pamhyr/doc/images/ - mkdir -p pamhyr/doc/html/ # - cp ../doc/users/documentation.pdf pamhyr/doc/Pamhyr2-users.pdf # - cp ../doc/users/documentation.html pamhyr/doc/Pamhyr2-users.html - cp ../doc/mage8.pdf pamhyr/doc/mage8.pdf - cp ../doc/dev/documentation.pdf pamhyr/doc/Pamhyr2-dev.pdf - cp ../doc/dev/documentation.html pamhyr/doc/Pamhyr2-dev.html #- cp ../doc/users/images/* pamhyr/doc/images - cp -r ../doc/dev/images/* pamhyr/doc/images - cp -r ../doc/images/* pamhyr/doc/images # Copy Tuto - mkdir -p pamhyr/doc/Tuto1/ - mkdir -p pamhyr/doc/Tuto1/data - cp ../doc/users/Tuto1/Hogneau_Engees2022.pdf pamhyr/doc/Tuto1/Hogneau_Engees2022.pdf - cp ../doc/users/Tuto1/step-by-step.pdf pamhyr/doc/Tuto1/Tuto1-en.pdf - cp ../doc/users/Tuto1/pas-a-pas.pdf pamhyr/doc/Tuto1/Tuto1-fr.pdf - cp ../doc/users/Tuto1/*.pamhyr pamhyr/doc/Tuto1/ - cp ../doc/users/Tuto1/data/* pamhyr/doc/Tuto1/data/ # Copy TP charriage - mkdir -p pamhyr/doc/TP_charriage/ - cp ../doc/users/TP_charriage/* pamhyr/doc/TP_charriage artifacts: paths: - linux/pamhyr build-windows: stage: build tags: - wine rules: - if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG needs: - job: dl-mage8-windows artifacts: true - job: dl-mage8-doc artifacts: true - job: set-version artifacts: true - job: build-lang artifacts: true - job: build-developers-doc artifacts: true # - job: build-users-doc # artifacts: true - job: build-td artifacts: true script: - mkdir windows - cd windows # Setup env - python -m pip install -U pip - python -m pip install -r ..\requirements.txt - python -m pip install -U -r ..\requirements.txt # Run Pyinstaller # - pyinstaller --noconsole -y ..\src\pamhyr.py - pyinstaller --hide-console hide-early -y ..\src\pamhyr.py # Create directory - mkdir pamhyr - dir - copy ..\packages\make-windows-dir.bat .\make-windows-dir.bat - .\make-windows-dir.bat artifacts: paths: - windows/pamhyr ############ # PACKAGES # ############ linux-package-tar: stage: package tags: - release - linux needs: # - job: test-linux - job: build-linux artifacts: true rules: - if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_TAG artifacts: paths: - linux/pamhyr-gnulinux.tar.xz script: - cd linux - tar --xz -cf pamhyr-gnulinux.tar.xz ./pamhyr --checkpoint=.100 windows-package-zip: stage: package tags: - release - linux needs: # - job: test-windows - job: build-windows artifacts: true rules: - if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_TAG artifacts: paths: - windows/pamhyr-windows.zip script: - cd windows - zip -r pamhyr-windows.zip pamhyr windows-package-exe: stage: package tags: - release - wine needs: # - job: test-windows - job: build-windows artifacts: true rules: - if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_TAG artifacts: paths: - windows/pamhyr-windows.exe script: - cd windows - copy ..\packages\make-windows-exe.bat make-windows-exe.bat - copy ..\packages\pamhyr.nsi pamhyr.nsi - .\make-windows-exe.bat ######## # HASH # ######## linux-build-hash: stage: hash tags: - release - linux needs: - job: build-linux artifacts: true rules: - if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG script: - cd linux - sha256sum -b pamhyr/pamhyr > pamhyr/pamhyr.sha256 artifacts: paths: - linux/pamhyr/pamhyr.sha256 windows-build-hash: stage: hash tags: - release - linux needs: - job: build-windows artifacts: true rules: - if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG script: - cd windows - sha256sum -b pamhyr/pamhyr.exe > pamhyr/pamhyr.exe.sha256 artifacts: paths: - windows/pamhyr/pamhyr.exe.sha256 pkg-hash: stage: hash tags: - release - linux needs: - job: linux-package-tar artifacts: true - job: windows-package-zip artifacts: true - job: windows-package-exe artifacts: true rules: - if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_TAG script: - cd windows - sha256sum -b pamhyr-windows.exe > pamhyr-windows.exe.sha256 - sha256sum -b pamhyr-windows.zip > pamhyr-windows.zip.sha256 - cd .. - cd linux - sha256sum -b pamhyr-gnulinux.tar.xz > pamhyr-gnulinux.tar.xz.sha256 artifacts: paths: - windows/pamhyr-windows.exe.sha256 - windows/pamhyr-windows.zip.sha256 - linux/pamhyr-gnulinux.tar.xz.sha256 ############# # ANTIVIRUS # ############# build-check-clamav: stage: antivirus tags: - release - linux needs: - job: build-linux artifacts: true - job: build-windows artifacts: true rules: - if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG script: - cd packages - ./clamav-scan.sh builds allow_failure: true pkg-check-clamav: stage: antivirus tags: - release - linux needs: - job: linux-package-tar artifacts: true - job: windows-package-zip artifacts: true - job: windows-package-exe artifacts: true rules: - if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_TAG script: - cd packages - ./clamav-scan.sh packages allow_failure: true ########### # RELEASE # ########### tag-release: stage: release tags: - release - linux needs: - job: linux-package-tar artifacts: true - job: windows-package-zip artifacts: true - job: windows-package-exe artifacts: true # - job: build-users-doc # artifacts: true - job: build-developers-doc artifacts: true - job: pkg-hash artifacts: true rules: - if: $CI_COMMIT_TAG artifacts: paths: - linux/pamhyr-gnulinux.tar.xz - windows/pamhyr-windows.zip - windows/pamhyr-windows.exe - linux/pamhyr-gnulinux.tar.xz.sha256 - windows/pamhyr-windows.zip.sha256 - windows/pamhyr-windows.exe.sha256 - doc/dev/documentation.pdf # - doc/users/documentation.pdf script: - cd packages release: name: '$CI_COMMIT_TAG' description: '$CI_COMMIT_TAG_MESSAGE' tag_name: '$CI_COMMIT_TAG' ref: '$CI_COMMIT_SHA' assets: links: - name: 'GNU/Linux CHECKSUM SHA256 (tar.xz)' url: '${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/linux/pamhyr-gnulinux.tar.xz.sha256' filepath: '/linux/pamhyr-gnulinux.tar.xz.sha256' link_type: 'package' - name: 'GNU/Linux (tar.xz)' url: '${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/linux/pamhyr-gnulinux.tar.xz' filepath: '/linux/pamhyr-gnulinux.tar.xz' link_type: 'package' - name: 'Windows CHECKSUM SHA256 (exe)' url: '${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/windows/pamhyr-windows.exe.sha256' filepath: '/windows/pamhyr-windows.exe.sha256' link_type: 'package' - name: 'Windows (exe)' url: '${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/windows/pamhyr-windows.exe' filepath: '/windows/pamhyr-windows.exe' link_type: 'package' - name: 'Windows CHECKSUM SHA256 (zip)' url: '${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/windows/pamhyr-windows.zip.sha256' filepath: '/windows/pamhyr-windows.zip.sha256' link_type: 'package' - name: 'Windows (zip)' url: '${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/windows/pamhyr-windows.zip' filepath: '/windows/pamhyr-windows.zip' link_type: 'package' - name: 'Dev documentations (pdf)' url: '${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/doc/dev/documentation.pdf' filepath: '/doc/dev/documentation.pdf' link_type: 'other'