Skip to content

ci(workflow): add manual cross-repo porting workflow#791

Merged
mivek merged 1 commit intomainfrom
copilot/add-port-changes-workflow
Apr 22, 2026
Merged

ci(workflow): add manual cross-repo porting workflow#791
mivek merged 1 commit intomainfrom
copilot/add-port-changes-workflow

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 21, 2026

Adds a new GitHub Actions workflow to generate cross-repo porting issues from a commit hash, supporting both Java→Python and Python→Java directions. The workflow fetches commit metadata/diff from the current repo and opens a structured issue in the sister repository with language-specific implementation guidance.

  • Workflow added

    • New file: .github/workflows/port-changes.yml
    • Trigger: workflow_dispatch with required commit_hash input
  • Repository/context resolution

    • Detects whether execution is in mivek/MetarParser or the sister repo
    • Sets target repository and source/target language outputs accordingly
  • Commit extraction + issue synthesis

    • Uses gh api to fetch:
      • commit title (first line)
      • full commit message
      • raw diff
    • Builds a markdown issue body including:
      • source commit link
      • full commit message
      • full diff
      • explicit porting instructions tailored to Java or Python conventions
  • Cross-repo issue creation

    • Creates an issue in the resolved sister repository via gh issue create
    • Uses CROSS_REPO_PAT for cross-repository permissions
    • Titles issue as port: <commit title> and assigns to copilot
on:
  workflow_dispatch:
    inputs:
      commit_hash:
        required: true
        type: string

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • checkstyle.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.14/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.14/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.14 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.14/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/MetarParser/MetarParser org.codehaus.plexus.classworlds.launcher.Launcher verify (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Create the file .github/workflows/port-changes.yml with the following exact content:

name: Port Changes to Sister Repository

on:
  workflow_dispatch:
    inputs:
      commit_hash:
        description: 'Commit hash from this repository to port to the sister repo'
        required: true
        type: string

jobs:
  port-changes:
    runs-on: ubuntu-latest
    permissions:
      contents: read

    steps:
      - name: Resolve repository context
        id: ctx
        run: |
          if [[ "${{ github.repository }}" == "mivek/MetarParser" ]]; then
            echo "target_repo=mivek/python-metar-taf-parser" >> "$GITHUB_OUTPUT"
            echo "source_lang=Java" >> "$GITHUB_OUTPUT"
            echo "target_lang=Python" >> "$GITHUB_OUTPUT"
          else
            echo "target_repo=mivek/MetarParser" >> "$GITHUB_OUTPUT"
            echo "source_lang=Python" >> "$GITHUB_OUTPUT"
            echo "target_lang=Java" >> "$GITHUB_OUTPUT"
          fi

      - name: Fetch commit metadata and diff
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          gh api "repos/${{ github.repository }}/commits/${{ inputs.commit_hash }}" \
            --jq '.commit.message | split("\n")[0]' > /tmp/commit_title.txt

          gh api "repos/${{ github.repository }}/commits/${{ inputs.commit_hash }}" \
            --jq '.commit.message' > /tmp/commit_message.txt

          gh api "repos/${{ github.repository }}/commits/${{ inputs.commit_hash }}" \
            -H "Accept: application/vnd.github.diff" \
            > /tmp/commit.diff

      - name: Build issue body
        run: |
          SOURCE_LANG="${{ steps.ctx.outputs.source_lang }}"
          TARGET_LANG="${{ steps.ctx.outputs.target_lang }}"
          COMMIT_URL="https://github.com/${{ github.repository }}/commit/${{ inputs.commit_hash }}"

          {
            echo "## Port \`${SOURCE_LANG}\` → \`${TARGET_LANG}\`"
            echo ""
            echo "Port commit [\`${{ inputs.commit_hash }}\`](${COMMIT_URL}) from the ${SOURCE_LANG} sister repository."
            echo ""
            echo "### Original commit message"
            echo ""
            echo '```'
            cat /tmp/commit_message.txt
            echo '```'
            echo ""
            echo "### Diff to port"
            echo ""
            echo '```diff'
            cat /tmp/commit.diff
            echo '```'
            echo ""
            echo "### Porting instructions"
            echo ""
            echo "1. **Understand the intent**: read the diff carefully — identify whether it is a feature, fix, refactor, etc. Do **not** translate code literally."
            echo "2. **Implement the equivalent** idiomatically in ${TARGET_LANG}, following the architecture and patterns already present in this repository."
            if [[ "${TARGET_LANG}" == "Java" ]]; then
              echo "3. **Java conventions to follow**:"
              echo "   - Add a \`Command\` implementation in the correct sub-package (\`command.common\`, \`command.metar\`, \`command.taf\`, or \`command.remark\`) and register it in the matching \`*CommandSupplier.buildCommands()\`."
              echo "   - Use \`io.github.mivek.utils.Regex\` (never raw \`java.util.regex\`) for all pattern matching."
              echo "   - Every class, method, field and package needs a Javadoc comment. Every new package needs a \`package-info.java\`."
              echo "   - All method parameters must be \`final\`. Classes not designed for inheritance must be \`final\`."
              echo "   - Human-readable strings go in \`internationalization/messages*.properties\` — never hardcoded."
              echo "   - ArchUnit rules: command classes must not depend on the \`parser\` package and must implement the local \`Command\` interface."
              echo "4. **Tests**: coverage thresholds are enforced (98% instruction / 96% branch / 97% complexity). Add or update tests to match the original change."
            else
              echo "3. **Python conventions to follow**:"
              echo "   - Add a \`Command\` class in the correct sub-package (\`command/\`) with a \`regex\` class attribute, \`can_parse(input)\`, and \`execute(weather_obj, input)\`."
              echo "   - Register the command in the matching \`*CommandSupplier\` (MetarCommandSupplier, TAFCommandSupplier, or common CommandSupplier)."
              echo "   - Use the \`_()\` function from \`commons.i18n\` for any user-visible strings — never hardcode them."
              echo "   - Regex patterns must use \`^\` and \`\$\` anchors (exact match)."
              echo "   - Flake8 must pass (max complexity 10; line length is unrestricted)."
              echo "4. **Tests**: mirror the test structure in \`metar_taf_parser/tests/\`. Run \`make test\` to verify."
            fi
            echo "5. **Open a pull request** whose title follows Conventional Commits: \`<type>(<scope>): <subject>\`."
          } > /tmp/issue_body.md

      ...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

Copilot AI changed the title [WIP] Add port changes to sister repository workflow ci(workflow): add manual cross-repo porting workflow Apr 21, 2026
Copilot AI requested a review from mivek April 21, 2026 14:31
@mivek mivek marked this pull request as ready for review April 22, 2026 09:33
@github-actions
Copy link
Copy Markdown

Please check on sonarcloud https://sonarcloud.io/project/pull_requests_list?id=io.github.mivek%3AmetarParser that the PR does not add any issue.

@mivek mivek force-pushed the copilot/add-port-changes-workflow branch from 4d2ea88 to bde67f9 Compare April 22, 2026 09:56
@sonarqubecloud
Copy link
Copy Markdown

@mivek mivek merged commit 8624f13 into main Apr 22, 2026
11 checks passed
@mivek mivek deleted the copilot/add-port-changes-workflow branch April 22, 2026 10:03
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 2.21.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants