diff --git a/.github/ci/recipe.yaml b/.github/ci/recipe.yaml index 96962b8bac..0579c19e42 100644 --- a/.github/ci/recipe.yaml +++ b/.github/ci/recipe.yaml @@ -4,7 +4,7 @@ # Adapted from the conda forge recipe context: name: parcels - version: 4.0.0alpha2 # The last number here needs to be bumped for each new alpha release + version: ${{ env.get('PARCELS_ALPHA_VERSION') }} package: name: ${{ name|lower }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26456e22f5..459f3faa84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,10 +3,9 @@ on: push: branches: - "main" + - "v4-dev" - "test-me/*" pull_request: - schedule: - - cron: "0 7 * * 1" # Run every Monday at 7:00 UTC concurrency: group: branch-${{ github.head_ref }} @@ -38,7 +37,7 @@ jobs: exit 1 cache-pixi-lock: - runs-on: ubuntu-slim + runs-on: ubuntu-latest needs: [should-run-ci] outputs: cache-key: ${{ steps.pixi-lock.outputs.cache-key }} @@ -195,3 +194,36 @@ jobs: with: name: Mypy report path: mypy-report + build-and-upload-nightly-parcels: # for alpha testing + needs: [cache-pixi-lock] + permissions: + contents: read + id-token: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + - name: Restore cached pixi lockfile + uses: Parcels-code/pixi-lock/restore@2b823a4a804631370fbde7e6088ee5db71a26c60 # TODO: Update to action in prefix-dev once available + with: + cache-key: ${{ needs.cache-pixi-lock.outputs.cache-key }} + - uses: prefix-dev/setup-pixi@v0.9.0 + with: + pixi-version: ${{ needs.cache-pixi-lock.outputs.pixi-version }} + cache: true + cache-write: ${{ github.event_name == 'push' && github.ref_name == 'v4-dev' }} # TODO: Update v4-dev to main when v4 is released + - run: pixi run get-parcels-alpha-version >> $GITHUB_ENV + - run: echo "PARCELS_ALPHA_VERSION is $PARCELS_ALPHA_VERSION" + - name: Build conda package + uses: prefix-dev/rattler-build-action@v0.2.34 + with: + recipe-path: .github/ci/recipe.yaml + - if: github.ref == 'refs/heads/v4-dev' + run: | + for pkg in $(find output -type f \( -name "*.conda" -o -name "*.tar.bz2" \) ); do + echo "Uploading ${pkg}" + rattler-build upload prefix -c parcels "${pkg}" + done + env: + PREFIX_API_KEY: ${{ secrets.PREFIX_API_KEY }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml deleted file mode 100644 index 52d80e0050..0000000000 --- a/.github/workflows/nightly.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Publish alpha version of Parcels - -on: - workflow_dispatch: - -permissions: - contents: read - id-token: write - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v5 - - name: Build conda package - uses: prefix-dev/rattler-build-action@v0.2.34 - with: - recipe-path: .github/ci/recipe.yaml - - - run: | - for pkg in $(find output -type f \( -name "*.conda" -o -name "*.tar.bz2" \) ); do - echo "Uploading ${pkg}" - rattler-build upload prefix -c parcels "${pkg}" - done - env: - PREFIX_API_KEY: ${{ secrets.PREFIX_API_KEY }} diff --git a/pixi.toml b/pixi.toml index 4dcbd65750..71ddfe96ed 100644 --- a/pixi.toml +++ b/pixi.toml @@ -35,6 +35,12 @@ py-triangle = ">=20250106,<20250107" [dependencies] parcels = { path = "." } +[feature.alpha-parcels.dependencies] +git = "*" + +[feature.alpha-parcels.tasks] +get-parcels-alpha-version = { cmd = "python tools/get-parcels-alpha-version.py" } + [feature.minimum.dependencies] python = "3.11.*" netcdf4 = "1.6.*" @@ -127,3 +133,4 @@ test-py313 = { features = ["test", "py313"] } test-notebooks = { features = ["test", "notebooks"], solve-group = "main" } docs = { features = ["docs", "notebooks"], solve-group = "docs" } typing = { features = ["typing"], solve-group = "main" } +alpha-parcels = { features = ["alpha-parcels"] } diff --git a/pyproject.toml b/pyproject.toml index ec55086064..392cd8a2c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,6 @@ dependencies = [ "netCDF4 >=1.7.2", "zarr >=2.15.0,!=2.18.0,<3", "tqdm >=4.50.0", - "pytest", "xarray >=2024.5.0", "uxarray >=2025.3.0", "pooch >=1.8.0", diff --git a/tools/get-parcels-alpha-version.py b/tools/get-parcels-alpha-version.py new file mode 100644 index 0000000000..a1438f91a2 --- /dev/null +++ b/tools/get-parcels-alpha-version.py @@ -0,0 +1,30 @@ +"""Get a Parcels v4 alpha version string based on commits since the last tag. + +Sets the PARCELS_ALPHA_VERSION environment variable (via GITHUB_ENV in CI, +or prints the version to stdout for local use). +""" + +import subprocess + + +def get_alpha_version(): + result = subprocess.run( + ["git", "describe", "--tags", "--long"], + capture_output=True, + text=True, + check=True, + ) + # Format: --g + # e.g. v3.1.2-1967-g1857d5219 + parts = result.stdout.strip().rsplit("-", 2) + n_commits = parts[1] + return f"4.0.0alpha{n_commits}" + + +def main(): + version = get_alpha_version() + print(f"PARCELS_ALPHA_VERSION={version}") + + +if __name__ == "__main__": + main()