Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next Steps GitQueue #44

Open
cgbosse opened this issue Feb 24, 2022 · 1 comment
Open

Next Steps GitQueue #44

cgbosse opened this issue Feb 24, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@cgbosse
Copy link
Member

cgbosse commented Feb 24, 2022

In todays meeting we did not have time to discuss the which of the following actions are to be developed next:

    • Action for building the payload?
    • Action for submodule update?
@cgbosse cgbosse added the enhancement New feature or request label Feb 24, 2022
@josecelano
Copy link
Member

Basically, I wanted to discuss if it makes sense to create two new very simple GitHub Actions:

  1. git-submodule-update
  2. git-submodule-update-messages

git-submodule-update

We need these two workflows steps:

An action to get the current and new commit hash after the submodule upgrade. I've not found any action to do that on the marketplace.

- name: Update submodule to get new commit ref
  id: update-submodule
  if: ${{ steps.get-next-job.outputs.job_found == 'false' }}
  shell: bash
  run: |
    git submodule status libraries/aaa
    PREVIOUS_REF=$(git submodule status | awk '{print $1}' | sed 's/-//' | sed 's/+//' | sed 's/U//')
    echo -e "::set-output name=previous_ref::$PREVIOUS_REF"
    git submodule update --remote libraries/aaa
    CURRENT_REF=$(git submodule status | awk '{print $1}' | sed 's/-//' | sed 's/+//' | sed 's/U//')
    echo -e "::set-output name=current_ref::$CURRENT_REF"
    UPDATED=$(if [ "$PREVIOUS_REF" != "$CURRENT_REF" ]; then echo "true"; else echo "false"; fi)
    echo -e "::set-output name=updated::$UPDATED"

And update the submodule to a given commit (not the latest one):

- name: Update submodule
  id: update-submodule
  if: ${{ steps.get-next-job.outputs.job_found == 'true' }}
  shell: bash
  run: |
    cd libraries/aaa
    git fetch --all
    git checkout ${{ steps.parse-payload.outputs.current_ref }} && echo "::set-output name=updated::true"

git-submodule-update-messages

The Git Queue action is a generic queue that could be used for any scheduled tasks not only for upgrading a git submodule as we are doing. So the message payload is defined by the queue action user. We have three inline workflows steps to do that:

New job message payload:

- name: Build job message payload
  id: build-payload
  if: ${{ steps.get-next-job.outputs.job_found == 'false' && steps.update-submodule.outputs.updated == 'true' }}
  shell: bash
  run: |
    PAYLOAD="Update Library Submodule and Process Changes:
    https://github.com/josecelano/library-aaa/commit/${{ steps.update-submodule.outputs.previous_ref }}
    ->
    https://github.com/josecelano/library-aaa/commit/${{ steps.update-submodule.outputs.current_ref }}
    
    PREVIOUS_REF=${{ steps.update-submodule.outputs.previous_ref }}
    CURRENT_REF=${{ steps.update-submodule.outputs.current_ref }}"
    PAYLOAD="${PAYLOAD//'%'/'%25'}"
    PAYLOAD="${PAYLOAD//$'\n'/'%0A'}"
    PAYLOAD="${PAYLOAD//$'\r'/'%0D'}"
    echo "::set-output name=payload::$(echo "$PAYLOAD")"

Mark job as started payload:

- name: Build job started message payload
  id: build-start-payload
  if: ${{ steps.get-next-job.outputs.job_found == 'true' }}
  shell: bash
  run: |
    PAYLOAD="Successfully started job according to specification in commit:
    https://github.com/josecelano/library-consumer/commit/${{ steps.get-next-job.outputs.job_commit }}"
    PAYLOAD="${PAYLOAD//'%'/'%25'}"
    PAYLOAD="${PAYLOAD//$'\n'/'%0A'}"
    PAYLOAD="${PAYLOAD//$'\r'/'%0D'}"
    echo "::set-output name=payload::$(echo "$PAYLOAD")"

Mark job as finished payload:

- name: Build job finished message payload
  id: build-finish-payload
  if: ${{ steps.start-job.outputs.job_started == 'true' }}
  shell: bash
  run: |
    PAYLOAD="Successfully finished job according to specification in commit:
    https://github.com/josecelano/library-consumer/commit/${{ steps.get-next-job.outputs.job_commit }}"
    PAYLOAD="${PAYLOAD//'%'/'%25'}"
    PAYLOAD="${PAYLOAD//$'\n'/'%0A'}"
    PAYLOAD="${PAYLOAD//$'\r'/'%0D'}"
    echo "::set-output name=payload::$(echo "$PAYLOAD")"

I think we could define a standard message format for updating submodules and build a small action to create and parse those messages. It would be a new "protocol" on top of GitQueue. It could be used to update any git submodule in any project. But maybe this one does not make any sense because each project will add its own metadata to the message. If that is the case I thing a embedded action in the project could be the solution, just to avoid using bash.

@josecelano josecelano transferred this issue from nautilus-cyberneering/git-queue May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants