Skip to content

[TASK] Adjust Github Actions so they run in order #195

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

Open
Dylan-Riley opened this issue Feb 25, 2021 · 7 comments · May be fixed by #233
Open

[TASK] Adjust Github Actions so they run in order #195

Dylan-Riley opened this issue Feb 25, 2021 · 7 comments · May be fixed by #233
Assignees
Labels
task New task, feature or request team2 Issues for Practicum Team 2
Milestone

Comments

@Dylan-Riley
Copy link
Contributor

Dylan-Riley commented Feb 25, 2021

Order:

  1. deploy-ui
  2. deploy-functions
  3. artillery-users
  4. artillery-users-user_id
  5. artillery-users-user_id-tasks
  6. artillery-users-user_id-tasks-task_id
  7. slsart-api-users
  8. slsart-api-users-user_id
  9. slsart-api-users-user_id-tasks
  10. slsart-api-users-user_id-tasks-task_id
  11. slsart-UI-users
  12. slsart-UI-users-user_id
  13. slsart-UI-users-user_id-tasks
  14. slsart-UI-users-user_id-tasks-task_id

Many will need to be renamed, a few might need adjusting.

Preliminary research makes it seem there's not a super elegant way to make workflows wait on other workflows.

From https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_run :

workflow_run
This event occurs when a workflow run is requested or completed, and allows you to execute a workflow based on the finished result of another workflow. For example, if your pull_request workflow generates build artifacts, you can create a new workflow that uses workflow_run to analyze the results and add a comment to the original pull request.

The workflow started by the workflow_run event is able to access the secrets and write tokens used by the original workflow.

Note: This event will only trigger a workflow run if the workflow file is on the default branch.


Also try to figure out #186

@Dylan-Riley Dylan-Riley added task New task, feature or request team2 Issues for Practicum Team 2 labels Feb 25, 2021
@Dylan-Riley Dylan-Riley self-assigned this Feb 25, 2021
@Dylan-Riley Dylan-Riley added this to the Sprint 04 milestone Feb 25, 2021
@Dylan-Riley
Copy link
Contributor Author

Dylan-Riley commented Feb 25, 2021

Add all artillery and serverless-artillery actions to their own respective workflows?

Can serverless-artillery deploy a single time before doing all eight tests/invokes then do a single remove?

Which of the workflows depend on which other workflows?

@Dylan-Riley
Copy link
Contributor Author

Find previous issues/PRs for the deploy actions (UI/functions) see exactly what those do, how long they take.

@Dylan-Riley
Copy link
Contributor Author

Dylan-Riley commented Feb 25, 2021

Read up on https://github.com/softprops/turnstyle

Looks more like it's used to prevent the same action running in parallel from multiple merges, but it might do

@Dylan-Riley
Copy link
Contributor Author

Okay, so this is fairly simple using on: repository_dispatch (See here) BUT the workflows need to be in the default branch!

Using

name: foo

on: [push]

jobs:
  workflow1:
    name: workflow 1
    runs-on: ubuntu-latest
    steps:
      - name: checkout code
        uses: actions/checkout@v2
      - name: wait fifteen seconds
        run: |
          echo foo
          sleep 15
      - name: Trigger next workflow
        if: success()
        uses: peter-evans/repository-dispatch@v1
        with:
          token: ${{ secrets.REPO_GHA_PAT }}
          repository: ${{ github.repository }}
          event-type: trigger-workflow-2
          client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'

and

name: bar

on: 
  repository_dispatch:
    types: [trigger-workflow-2]

jobs:
  workflow2:
    name: workflow 2
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.event.client_payload.sha }}
      - run: echo bar

I was able to get a proof of concept, but multiple people testing any sweeping changes I make will not work
image

Therefore, I have decided only to edit the existing workflows as of 4/MAR/2021 to trigger each other sequentially. I will not be doing any of the extra edits suggested in #195 (comment)

@Dylan-Riley
Copy link
Contributor Author

I also needed to add a secret that is a github Personal Access Token in order to get all the permissions needed. All this token has access to is the repo and workflow scopes, everything else is not included
image

@Dylan-Riley
Copy link
Contributor Author

Previous Workflow Filename Function New Filename Order
artillery-action-users-api.yml test users function with artillery artillery-users.yml 3
artillery-action-users-id-tasks-id.yaml test users/{user_id}/tasks/{task_id} function with artillery artillery-users-user_id-tasks-task_id.yml 6
artillery-test-users-user_id-tasks.yaml test users/{user_id}/tasks function with artillery artillery-users-user_id-tasks.yml 5
artillerytest-performance-user.yml Seemingly was supposed to be a slsart test, horribly broken DELETED N/A
deploy-apis.yaml deploy api functions deploy-functions.yml 2
deploy-ui.yml deploy UI deploy-ui.yml 1
performancetest-users-userID.yaml slsart test users/{user_id} (need to rename and move test script file) slsart-api-users-user_id 8
performancetest.yml unspecified slsart test, would work but doesn't do anything DELETED N/A
serverless-artillery-action-users-id-tasks-api.yml (From #175) slsart test users/{user_id}/tasks slsart-api-users-user_id-tasks.yml 9
serverless-artillery-test-users-api.yml slsart test users slsart-api-users.yml 7
serverless-artilleryreport-users-user_id-tasks.yml Old version of step 9, would have been removed with #175 DELETED N/A
sql-injection-post-users-userid-tasks.yml SQL injection test? Not on my list unchanged last
ui-tests-users.yaml test the UI of users, not a slsart test unchanged tentative 11

@Dylan-Riley
Copy link
Contributor Author

Only ten working (presumably) workflows in /.github/workflows/ total, two of which aren't technically on my list.

Missing:

  • artillery test for users/{user_id}
  • serverless-artillery test for users/{user_id}/tasks/{task_id}
  • All slsart UI tests
  • Any UI testing aside from /users/

@Dylan-Riley Dylan-Riley linked a pull request Mar 4, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
task New task, feature or request team2 Issues for Practicum Team 2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant