Skip to content

Conversation

josecelano
Copy link
Member

Issue: #21

@josecelano josecelano linked an issue Feb 9, 2022 that may be closed by this pull request
@josecelano josecelano added the enhancement New feature or request label Feb 9, 2022
@github-actions
Copy link

github-actions bot commented Feb 9, 2022

MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ ACTION actionlint 4 0 0.09s
✅ COPYPASTE jscpd yes no 1.23s
✅ CREDENTIALS secretlint yes no 0.81s
✅ GIT git_diff yes no 0.01s
✅ JAVASCRIPT standard 1 0 0 1.24s
✅ JSON eslint-plugin-jsonc 7 0 0 0.84s
✅ JSON jsonlint 7 0 1.59s
✅ JSON prettier 7 0 0 1.24s
✅ JSON v8r 7 0 7.5s
✅ MARKDOWN markdownlint 2 0 0 0.3s
✅ MARKDOWN markdown-link-check 2 0 1.28s
✅ MARKDOWN markdown-table-formatter 2 0 0 0.27s
✅ SPELL cspell 69 0 2.81s
✅ SPELL misspell 69 0 0 0.12s
✅ TYPESCRIPT eslint 43 0 0 10.67s
✅ YAML prettier 7 0 0 1.26s
✅ YAML v8r 7 0 6.47s
✅ YAML yamllint 7 0 0.2s

See errors details in artifact MegaLinter reports on CI Job page

@josecelano
Copy link
Member Author

josecelano commented Feb 9, 2022

I've changed the message classes names and changed the commit subject prefixes to use emojis.

TODO:

  • Include queue name
  • Include job reference (the commit hash where the job was added to the queue)

Include queue name:

📝🈺: queue_name
📝✅: queue_name

Include job commit reference (final state for this PR):

📝🈺: queue_name
📝✅: queue_name: job.ref.1e31b549c630f806961a291b4e3d4a1471f37490

Since the queue does not allow yet more than one job I'm not going to implement in the PR the full specification on issue #21.

Copy link
Collaborator

@yeraydavidrodriguez yeraydavidrodriguez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just a minor observation and my opinion on the open question.

@josecelano
Copy link
Member Author

hi @yeraydavidrodriguez @da2ce7 I've just realized that in order to add the job reference (commit hash) on the "finish job" commit subject I need to know (ovbiously) the hash:

📝✅: queue_name: job.ref.1e31b549c630f806961a291b4e3d4a1471f37490

I can add an argument to the action command and let the workflow handle that.

Workflow:

- name: Mark job as finished
  id: finish-job
  if: ${{ steps.create-job.outputs.job_created == 'true' }}
  uses: ./
  with:
    git_repo_dir: ${{ runner.temp }}/temp_git_dir
    queue_name: 'Library Update [library-aaa]'
    action: 'finish-job'
    job_payload: '{"field": "value", "state": "finished"}'
    new_job_commit: "1e31b549c630f806961a291b4e3d4a1471f37490"

src/main.ts:

const markJobAsFinishedCommit = await queue.markJobAsFinished(
  inputs.jobPayload,
  inputs.newJobCommit, /* the commit where the job was created */
  commitOptions
)

Notice the new inputs.newJobCommit argument.

In the long run, we are going to add job ids, and I think maybe it makes more sense to pass the job id instead of the commit hash. Internally we can search for the commit hash.

If you prefer to use the job id I can finish this PR without adding that part (job.ref.1e31b549c630f806961a291b4e3d4a1471f37490) and create a new issue to add job ids. In fact, I think it's a good idea to add job ids with a single job, before implementing the N-pending-jobs queue.

@josecelano
Copy link
Member Author

hi @yeraydavidrodriguez @da2ce7 I've just realized that in order to add the job reference (commit hash) on the "finish job" commit subject I need to know (ovbiously) the hash:

📝✅: queue_name: job.ref.1e31b549c630f806961a291b4e3d4a1471f37490

I can add an argument to the action command and let the workflow handle that.

Workflow:

- name: Mark job as finished
  id: finish-job
  if: ${{ steps.create-job.outputs.job_created == 'true' }}
  uses: ./
  with:
    git_repo_dir: ${{ runner.temp }}/temp_git_dir
    queue_name: 'Library Update [library-aaa]'
    action: 'finish-job'
    job_payload: '{"field": "value", "state": "finished"}'
    new_job_commit: "1e31b549c630f806961a291b4e3d4a1471f37490"

src/main.ts:

const markJobAsFinishedCommit = await queue.markJobAsFinished(
  inputs.jobPayload,
  inputs.newJobCommit, /* the commit where the job was created */
  commitOptions
)

Notice the new inputs.newJobCommit argument.

In the long run, we are going to add job ids, and I think maybe it makes more sense to pass the job id instead of the commit hash. Internally we can search for the commit hash.

If you prefer to use the job id I can finish this PR without adding that part (job.ref.1e31b549c630f806961a291b4e3d4a1471f37490) and create a new issue to add job ids. In fact, I think it's a good idea to add job ids with a single job, before implementing the N-pending-jobs queue.

Ignore my previous comment. With my fresh brain in the morning, I see I can get the commit because there is only one pending job. I was already thinking about multiple jobs. In fact, before adding the "finish" commit I check that there is a pending job and I have the commit hash in the StoredMessage.

Anyway, I think it's a good idea the split the multi-job issue into 2 issues. We can implement first an issue to add the job number and then allow multiple pending jobs.

The commit subject for the JobFinihsedMessage now contains the
a referecne (commit) to the commit were the job was created.

📝🈺: queue-name: job.ref.f1a69d48a01cc130a64aeac5eaf762e4ba685de7
The commits with an standard subject without the queue refix must be be
discarded.
@josecelano
Copy link
Member Author

josecelano commented Feb 11, 2022

The feature is finished but I want to refactor some parts of the code (minor changes, extract some classes to move validation to them).

  • Extract class CommitHash
  • Extract class QueueName
  • Extract class MessageKey
  • Refactor class CommitSubject. Add parts as attributes and add validation.
  • Rename class StoredMessage to CommittedMessage

@josecelano josecelano requested a review from da2ce7 February 11, 2022 16:59
@josecelano josecelano marked this pull request as ready for review February 14, 2022 16:51
@josecelano
Copy link
Member Author

hi @yeraydavidrodriguez @da2ce7 this is finished.

@josecelano josecelano merged commit 755d99b into main Feb 15, 2022
@josecelano josecelano deleted the issue-21-refactor-wording branch February 15, 2022 09:19
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

Successfully merging this pull request may close these issues.

Refactor: wording
2 participants