Skip to content

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

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

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

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 21, 2026

  • Identify all run blocks that directly interpolate ${{ inputs.commit_hash }}
  • Fix "Fetch commit metadata and diff" step: move input to env.COMMIT_HASH, use $COMMIT_HASH in shell
  • Fix "Build issue body" step: move input to env.COMMIT_HASH, use $COMMIT_HASH in shell
  • Run validation checks — Code Review: no issues; CodeQL: 0 alerts
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 workflow to sister repository ci(workflows): add manual cross-repo porting workflow Apr 21, 2026
Copilot AI requested a review from mivek April 21, 2026 14:32
@mivek mivek marked this pull request as ready for review April 22, 2026 10:04
@mivek mivek force-pushed the copilot/add-port-changes-workflow branch from 1fd348e to 10ac0f8 Compare April 22, 2026 10:39
@sonarqubecloud
Copy link
Copy Markdown

@mivek mivek merged commit 82df6a3 into main Apr 22, 2026
9 checks passed
@mivek mivek deleted the copilot/add-port-changes-workflow branch April 22, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants