From e9beb57fc8dead68de3e7ae192f93223dbfd2c1a Mon Sep 17 00:00:00 2001 From: "r.jaepel" Date: Fri, 15 Nov 2024 12:13:41 +0100 Subject: [PATCH] Migrate CI to GitHub Actions --- .github/workflows/publish_to_pypi.yml | 100 ++++++++++++++++++++++++++ .gitlab-ci.yml | 31 -------- pyproject.toml | 4 +- 3 files changed, 102 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/publish_to_pypi.yml delete mode 100644 .gitlab-ci.yml diff --git a/.github/workflows/publish_to_pypi.yml b/.github/workflows/publish_to_pypi.yml new file mode 100644 index 0000000..2dd43d1 --- /dev/null +++ b/.github/workflows/publish_to_pypi.yml @@ -0,0 +1,100 @@ +name: Publish CADET-RDM to PyPI + +on: + push: + branches: + - master + - dev + - test_ci + tags: + - 'v*.*.*' # Trigger build stage only on version tags + pull_request: + branches: + - '**' # Trigger test stage on pull requests to any branch + +jobs: + test-stage: + runs-on: ${{ matrix.os }} + + defaults: + run: + shell: bash -l {0} + + strategy: + matrix: + os: [ ubuntu-latest ] + python-version: [ "3.10", "3.11", "3.12" ] + include: + - os: windows-latest + python-version: "3.12" + - os: macos-12 + python-version: "3.12" + + steps: + - name: Checkout Code + uses: actions/checkout@master + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Git LFS + if: runner.os == 'Linux' || runner.os == 'macOS' + run: | + sudo apt-get update + sudo apt-get install -y git-lfs + git lfs install + + - name: Configure Git # This is required for the test suite, which checks git credentials + run: | + git config --global user.email "you@example.com" + git config --global user.name "Your Name" + + - name: Set up Virtual Environment + run: | + python -m venv ../testing + ${{ runner.os == 'Windows' && 'source ../testing/Scripts/activate' || 'source ../testing/bin/activate' }} + + - name: Install Dependencies + run: | + pip install -U pytest setuptools + pip install .[testing] + + - name: Verify Installation + run: | + pip list + ls -l + + - name: Run Tests + run: | + pytest tests -m "not server_api" + + build-release: + name: Build and Upload Release + runs-on: ubuntu-latest + needs: test-stage # Ensure this job runs only after test-stage succeeds + if: startsWith(github.ref, 'refs/tags/v') + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.12 + + - name: Install Build Tools + run: | + pip install -U build twine + + - name: Build the Package + run: | + python -m build + + - name: Upload to PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN }} + run: | + python -m twine upload dist/* diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 10bb407..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,31 +0,0 @@ -image: python:3.12 - -stages: - - test - - build - -test-stage: - stage: test - script: - - apt-get update - - apt-get install git-lfs - - git config --global user.email "you@example.com" - - git config --global user.name "Your Name" - - cd .. - - python -m venv testing - - source testing/bin/activate - - cd CADET-RDM - - pip install -U pytest setuptools - - pip install .[testing] - - pip list - - ls -l - - pytest tests -m "not server_api" - -build-release: - rules: - - if: $CI_COMMIT_TAG =~ /^v?\d+\.\d+\.\d+.*/ - stage: build - script: - - pip install -U build twine - - python -m build - - python -m twine upload dist/* diff --git a/pyproject.toml b/pyproject.toml index 1badc0f..3f840b9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,9 +37,9 @@ rdm = "cadetrdm.cli_integration:cli" [project.urls] -homepage = "https://jugit.fz-juelich.de/IBG-1/ModSim/cadet/CADET-RDM" +homepage = "https://github.com/cadet/CADET-RDM" documentation = "https://cadet-rdm.readthedocs.io/en/latest/index.html" -"Bug Tracker" = "https://jugit.fz-juelich.de/IBG-1/ModSim/cadet/CADET-RDM/Issues" +"Bug Tracker" = "https://github.com/cadet/CADET-RDM/issues" [project.optional-dependencies]