From 10ac0f8970bda03e248c50cbc4d2b74c7579b3b1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Apr 2026 14:25:34 +0000 Subject: [PATCH] ci(workflows): add port-changes workflow for sister repository issue creation Agent-Logs-Url: https://github.com/mivek/python-metar-taf-parser/sessions/db00ecaa-5e43-4dba-8bb3-c3c0d76bb3e8 Co-authored-by: mivek <9912558+mivek@users.noreply.github.com> --- .github/workflows/port-changes.yml | 105 +++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 .github/workflows/port-changes.yml diff --git a/.github/workflows/port-changes.yml b/.github/workflows/port-changes.yml new file mode 100644 index 0000000..249e08b --- /dev/null +++ b/.github/workflows/port-changes.yml @@ -0,0 +1,105 @@ +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 }} + COMMIT_HASH: ${{ inputs.commit_hash }} + run: | + gh api "repos/${{ github.repository }}/commits/$COMMIT_HASH" \ + --jq '.commit.message | split("\n")[0]' > /tmp/commit_title.txt + + gh api "repos/${{ github.repository }}/commits/$COMMIT_HASH" \ + --jq '.commit.message' > /tmp/commit_message.txt + + gh api "repos/${{ github.repository }}/commits/$COMMIT_HASH" \ + -H "Accept: application/vnd.github.diff" \ + > /tmp/commit.diff + + - name: Build issue body + env: + COMMIT_HASH: ${{ inputs.commit_hash }} + run: | + SOURCE_LANG="${{ steps.ctx.outputs.source_lang }}" + TARGET_LANG="${{ steps.ctx.outputs.target_lang }}" + COMMIT_URL="https://github.com/${{ github.repository }}/commit/$COMMIT_HASH" + + { + echo "## Port \`${SOURCE_LANG}\` → \`${TARGET_LANG}\`" + echo "" + echo "Port commit [\`${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: \`(): \`." + } > /tmp/issue_body.md + + - name: Create issue in target repository + env: + GH_TOKEN: ${{ secrets.CROSS_REPO_PAT }} + run: | + TITLE="port: $(cat /tmp/commit_title.txt)" + gh issue create \ + --repo "${{ steps.ctx.outputs.target_repo }}" \ + --title "$TITLE" \ + --body-file /tmp/issue_body.md \ + --assignee "copilot"