From c98e48bf34c68bbf21d6f2e3e44f69effc2087a1 Mon Sep 17 00:00:00 2001 From: Matt Austin Date: Thu, 16 May 2024 17:51:55 -0700 Subject: [PATCH 1/9] Gitlab_cleanup (#28) * Chnaged key name and fixed "no changes" bug * Clean up and added URL from env option. * Added docker ignore files * Added a bash script to clean up ci yaml. Intruduces PIXEE_OPTS. Should allow a run without a merge request * Fixes for "full" run. * Fix Lint errors --- ci/examples/bitbucket-pipelines.yml | 1 + ci/gitlab/pipeline.py | 2 ++ docker/Dockerfile | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ci/examples/bitbucket-pipelines.yml b/ci/examples/bitbucket-pipelines.yml index a3ff114..5e00f11 100644 --- a/ci/examples/bitbucket-pipelines.yml +++ b/ci/examples/bitbucket-pipelines.yml @@ -1,5 +1,6 @@ image: atlassian/default-image:4 + pipelines: pull-requests: '**': # This will run for pull requests targeting any branch diff --git a/ci/gitlab/pipeline.py b/ci/gitlab/pipeline.py index fa50ce7..fa255dd 100644 --- a/ci/gitlab/pipeline.py +++ b/ci/gitlab/pipeline.py @@ -8,7 +8,9 @@ # GitLab settings + gitlab_url = os.environ.get("GITLAB_API_URL", "https://gitlab.com") + api_token = os.environ.get("GITLAB_API_TOKEN_PIXEE") project_id = os.environ.get("CI_MERGE_REQUEST_PROJECT_ID") or os.environ.get( "CI_PROJECT_ID" diff --git a/docker/Dockerfile b/docker/Dockerfile index 13d8c2d..fee4774 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -18,4 +18,4 @@ RUN unzip codemodder-java-codemods-0.72.2.zip RUN python3 -m pip install pixee COPY bin ./bin -ENV PATH="${PATH}:/pixee/bin" \ No newline at end of file +ENV PATH="${PATH}:/pixee/bin" From b6b3e6e390dcf8bb4a416bef6ba64c808a88fc9e Mon Sep 17 00:00:00 2001 From: Matt Austin Date: Thu, 16 May 2024 18:02:03 -0700 Subject: [PATCH 2/9] Update docker_test.yaml --- .github/workflows/docker_test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker_test.yaml b/.github/workflows/docker_test.yaml index ec9b64f..1ea583e 100644 --- a/.github/workflows/docker_test.yaml +++ b/.github/workflows/docker_test.yaml @@ -48,4 +48,4 @@ jobs: context: "{{defaultContext}}:docker" file: ./Dockerfile push: true - tags: pixeematt/pixee-cli:latest, pixeematt/pixee-cli:${{ steps.bump-semver.outputs.new_version }} + tags: codemodder/pixee-cli:latest, codemodder/pixee-cli:${{ steps.bump-semver.outputs.new_version }} From 2b66e6b22dd0fe51f820785a8484d68ecdcc2dba Mon Sep 17 00:00:00 2001 From: Matt Austin Date: Thu, 16 May 2024 18:06:07 -0700 Subject: [PATCH 3/9] Update docker_test.yaml --- .github/workflows/docker_test.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/docker_test.yaml b/.github/workflows/docker_test.yaml index 1ea583e..2086f33 100644 --- a/.github/workflows/docker_test.yaml +++ b/.github/workflows/docker_test.yaml @@ -2,6 +2,9 @@ name: Manual Docker Build and Publish on: workflow_dispatch: # This enables manual trigger from GitHub UI or API + push: + branches: + - main jobs: build_and_publish: From 2a813e24140423fada0ef45c4f7941377dd75e22 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 18:17:09 -0700 Subject: [PATCH 4/9] Update dependency codemodder to v0.100.0 (#37) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bfb6dfa..7083bd2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ readme = "README.md" license = {file = "LICENSE"} description = "Pixee CLI" dependencies = [ - "codemodder==0.91.0", + "codemodder==0.100.0", "click", "prompt-toolkit", "questionary~=2.0.0", From 7f53ef99a78a4cebfdaf0f2df46bf55a0e9f598b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 18:18:03 -0700 Subject: [PATCH 5/9] Update pre-commit/action action to v3.0.1 (#31) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8c1d340..5d488c1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -39,4 +39,4 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 - - uses: pre-commit/action@v3.0.0 + - uses: pre-commit/action@v3.0.1 From 37ebec52c32e8c65c95722d99653a03783d954ff Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 18:19:02 -0700 Subject: [PATCH 6/9] Update python Docker tag to v3.13 (#32) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index fee4774..4fcf5c4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.11-rc-bullseye +FROM python:3.13-rc-bullseye WORKDIR /pixee RUN apt-get update From 6aeddf0fa290d9e970bb21a70f292c017a38355a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 18:20:22 -0700 Subject: [PATCH 7/9] Update codemodder/pixee-cli Docker tag to v0.8.5 (#34) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- ci/bitbucket/Dockerfile | 2 +- ci/gitlab/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/bitbucket/Dockerfile b/ci/bitbucket/Dockerfile index 5f5f619..465d3b2 100644 --- a/ci/bitbucket/Dockerfile +++ b/ci/bitbucket/Dockerfile @@ -1,4 +1,4 @@ -FROM codemodder/pixee-cli:0.0.1 +FROM codemodder/pixee-cli:0.8.5 COPY . /pixee/bitbucket WORKDIR /pixee/bitbucket RUN pip install whatthepatch load_dotenv diff --git a/ci/gitlab/Dockerfile b/ci/gitlab/Dockerfile index c542e5f..f3d50f2 100644 --- a/ci/gitlab/Dockerfile +++ b/ci/gitlab/Dockerfile @@ -1,4 +1,4 @@ -FROM codemodder/pixee-cli:0.0.1 +FROM codemodder/pixee-cli:0.8.5 COPY . /pixee/gitlab WORKDIR /pixee/gitlab RUN pip install -r requirements.txt From 54bdebc778cac7d63af8929952929ff1463049f5 Mon Sep 17 00:00:00 2001 From: Matt Austin Date: Thu, 16 May 2024 18:48:46 -0700 Subject: [PATCH 8/9] Revert "Update python Docker tag to v3.13" (#51) Revert "Update python Docker tag to v3.13 (#32)" This reverts commit 37ebec52c32e8c65c95722d99653a03783d954ff. --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 4fcf5c4..fee4774 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.13-rc-bullseye +FROM python:3.11-rc-bullseye WORKDIR /pixee RUN apt-get update From 33c5a4b9a4d291107690ef2f27fabd4dc13646b9 Mon Sep 17 00:00:00 2001 From: Matt Austin Date: Thu, 16 May 2024 19:10:03 -0700 Subject: [PATCH 9/9] Docker run (#50) * Added entrypoint to docker image. * Added information about running in docker. * Fix sonar issue * Fix sonar redirect complaint * Clean up docker image a bit --- README.md | 9 +++++++++ docker/Dockerfile | 20 ++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index e0072e4..67f2b9c 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,15 @@ To simply scan some code and see possible changes to make: pixee fix /my/project/directory/ ``` +## Docker Usage + +Pixee can also be run in a Docker container. This is useful if you want to run Pixee on an oerating system that does not support brew, or a CI/CD pipeline or in a containerized environment. + +``` +docker run --rm -it -v "${PWD}:/src" codemodder/pixee-cli fix /src + +``` + ## F.A.Q. ### What languages are supported for fixes? diff --git a/docker/Dockerfile b/docker/Dockerfile index fee4774..4a80808 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,21 +1,17 @@ FROM python:3.11-rc-bullseye WORKDIR /pixee -RUN apt-get update +ENV CODEMODDER_JAVA_VERSION=0.75.1 -# Install Python 3, pip and wget -RUN apt-get install -y wget unzip openjdk-17-jre - -RUN ln -s /usr/bin/python3 /usr/bin/python && \ - java -version && \ - python --version && \ - python3 -m pip install semgrep==1.15.0 && \ - python3 -m pip install codemodder - -RUN wget https://github.com/pixee/codemodder-java/releases/download/v0.72.2/codemodder-java-codemods-0.72.2.zip -RUN unzip codemodder-java-codemods-0.72.2.zip +RUN apt-get update && apt-get --no-install-recommends install -y wget unzip openjdk-17-jre && apt-get clean && rm -rf /var/lib/apt/lists/* +RUN wget --max-redirect=1 "https://github.com/pixee/codemodder-java/releases/download/v${CODEMODDER_JAVA_VERSION}/codemodder-java-codemods-${CODEMODDER_JAVA_VERSION}.zip" +RUN unzip codemodder-java-codemods-*.zip && rm codemodder-java-codemods-*.zip RUN python3 -m pip install pixee COPY bin ./bin ENV PATH="${PATH}:/pixee/bin" + +WORKDIR /src + +ENTRYPOINT ["pixee"]