Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,30 @@ jobs:
- name: check-java
run: java --version

- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Uv
uses: astral-sh/setup-uv@v4

- name: Install Poetry
uses: snok/install-poetry@v1
- name: "Set up Python"
uses: actions/setup-python@v5
with:
version: 1.8.1
plugins: poetry-plugin-export
python-version-file: "rewrite/.python-version"

- name: build-java
run: ./gradlew ${{ env.GRADLE_SWITCHES }} build

- name: build-python
- name: Install dependencies
run: |
cd rewrite
uv python install
uv sync --all-extras

# - name: Run tests
# run: |
# poe test

- name: Run build
run: |
for directory in rewrite/rewrite-*/; do
if [ -f "$directory/pyproject.toml" ]; then
echo "Building project in $directory"
cd "$directory"
poetry install --no-interaction --no-ansi
poetry build
poetry run pytest
cd - > /dev/null
fi
done
uv build

- name: publish-snapshots
if: github.event_name != 'pull_request'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/comment-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
workflow_run:
workflows: ["receive-pr"]
types:
- completed
# - completed

# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
# Since this pull request has write permissions on the target repo, we should **NOT** execute any untrusted code.
Expand Down
19 changes: 11 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ jobs:
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
python-version: "3.12"

- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install uv
uses: astral-sh/setup-uv@v4

- name: publish-candidate
if: contains(github.ref, '-rc.')
Expand Down Expand Up @@ -78,15 +78,18 @@ jobs:
echo "Extracted version: $version"
echo "::set-output name=VERSION::$version"

- name: Set project version with Poetry
- name: Set project version
working-directory: rewrite
run: poetry version ${{ steps.extract_version.outputs.VERSION }}
run: |
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version ${{ steps.extract_version.outputs.VERSION }}

- name: publish-python
working-directory: rewrite
if: (!contains(github.ref, '-rc.'))
run: |
poetry install --no-interaction --no-ansi
poetry build
poetry publish --username __token__ --password ${{ secrets.PYPI_TOKEN }}
rm -rf .venv
uv python install
uv sync --all-extras
uv build
uv publish --token ${{ secrets.PYPI_TOKEN }}
git restore --staged --worktree . && git clean -fd
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ build/
out/
bin/
example-data/
.idea/
.idea/

.DS_Store
11 changes: 5 additions & 6 deletions rewrite-python/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies {
testImplementation("org.junit-pioneer:junit-pioneer:latest.release")
}

val poetryProjectDir = file("../rewrite")
val pythonProjectDir = file("../rewrite")
val outputDir = layout.buildDirectory.dir("resources/main/META-INF")
val requirementsFile = outputDir.map { it.file("python-requirements.txt") }

Expand All @@ -40,19 +40,18 @@ tasks.register("prepareOutputDir") {
}
}

tasks.register<Exec>("exportPoetryRequirements") {
tasks.register<Exec>("exportPythonRequirements") {
dependsOn("prepareOutputDir")
workingDir = poetryProjectDir
commandLine("sh", "-c", "poetry export --without-hashes -o ${requirementsFile.get().asFile.absolutePath}")
workingDir = pythonProjectDir
commandLine("sh", "-c", "uv export --no-header --frozen --no-hashes --no-emit-project --no-dev --no-emit-package openrewrite-remote -o ${requirementsFile.get().asFile.absolutePath}")
standardOutput = System.out
errorOutput = System.err
}

tasks.register("appendOpenRewriteRequirements") {
dependsOn("exportPoetryRequirements")
dependsOn("exportPythonRequirements")
doLast {
val file = requirementsFile.get().asFile
file.appendText("cbor2\n")
file.appendText("openrewrite${generatePipVersionConstraint(project.version.toString(), false)}\n")
file.appendText("openrewrite-remote${generatePipVersionConstraint(getDirectDependencyVersion("org.openrewrite:rewrite-remote-java"), true)}\n")
}
Expand Down
2 changes: 1 addition & 1 deletion rewrite/.python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.12
3.12
Loading
Loading