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

The CI for the library should offer a repository dispatch #1021

Closed
jason-fox opened this issue Apr 15, 2021 · 10 comments
Closed

The CI for the library should offer a repository dispatch #1021

jason-fox opened this issue Apr 15, 2021 · 10 comments

Comments

@jason-fox
Copy link
Contributor

jason-fox commented Apr 15, 2021

Related to telefonicaid/lightweightm2m-iotagent#248 (comment)

At the moment whenever changes are made in the IoT Agent Node library in this repo here, they are not witnessed downstream until a new build is triggered. The CI for this repo should offer a trigger to the IoT Agents whenever code is successfully merged into master. An exisiting GitHub Action can already do this provided that a PAT token is added a a secret within this repository. You'll need something like:

jobs:
  build:
    # Main workflow job that builds, tests, etc.

  dispatch:
    if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
    strategy:
      matrix:
        repo: ['telefonicaid/iotagent-json, 'telefonicaid/iotagent-ul, 'telefonicaid/iotagent-lightweightm2m-iotagent']
    runs-on: ubuntu-latest
    steps:
      - name: Repository Dispatch
        uses: peter-evans/repository-dispatch@v1
        with:
          token: ${{ secrets.REPO_ACCESS_TOKEN }}
          repository: ${{ matrix.repo }}
          event-type: iot-agent-node-lib

Each of the IoT Agents CI could then be altered to handle both a manual trigger and the iot-agent-node-lib event e.g.:

name: CI
'on':
  push:
    branches:
      - master
  pull_request:
    branches:
      - master
  repository_dispatch:
    types:
      - iot-agent-node-lib
  workflow_dispatch:

This would avoid nasty discoveries if any downstream project is relying on something it shouldn't.

@fgalan
Copy link
Member

fgalan commented Sep 14, 2021

PRs related with this issue:

GitHub has auto-close this issue, but maybe is wiser to let it opened while we can check that the system is working

@fgalan fgalan reopened this Sep 14, 2021
@fgalan fgalan pinned this issue Sep 14, 2021
@jason-fox
Copy link
Contributor Author

Even better would be to close it after we've got dispatch working with FIWARE/iotagent-isoxml - I guess you'll need a FIWARE PAT (with minimal rights) from me right? Assuming TEF can dispatch to FF, this should also be extended to informing ATOS (for the LoRaWAN IoT Agent)

@fgalan
Copy link
Member

fgalan commented Sep 14, 2021

No problem in adding additional token as tokens in this repo... however, how this could be managed in ci.yml? What we have now is:

        with:
          token: ${{ secrets.REPO_ACCESS_TOKEN }}
          repository: ${{ matrix.repo }}
          event-type: iot-agent-node-lib

But I understand more of these secrets.xxxx should be added there (i.e. REPO_ACCESS_TOKEN_FF, REPO_ACCESS_TOKEN_ATOS, etc.).

@fgalan
Copy link
Member

fgalan commented Sep 14, 2021

IOTAManager was missing. The following PRs cover it:

@fgalan
Copy link
Member

fgalan commented Sep 14, 2021

Not sure if the system is working properly... Just after merging PR #1104 CI actions we can see at https://github.com/telefonicaid/iotagent-node-lib/runs/3598938988?check_suite_focus=true

imagen

So it seems the dispatch job has not been executed.

In fact, if we see for instance iotagent-ul actions (https://github.com/telefonicaid/iotagent-ul/actions) we can si last action was 2 hours ago...

imagen

Any clue?

@jason-fox
Copy link
Contributor Author

jason-fox commented Sep 14, 2021

There is something wrong with the if

if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true

The test run didn't include that filter.

@jason-fox
Copy link
Contributor Author

It looks like github.event.pull_request.merged has changed - its now just a github.event_name == 'push'

if: ${{ github.ref == 'refs/heads/master' }}

or

if: ${{ github.ref == 'refs/heads/master'  && github.event_name == 'push' }}

should be sufficient

@fgalan
Copy link
Member

fgalan commented Sep 14, 2021

...
or

if: ${{ github.ref == 'refs/heads/master'  && github.event_name == 'push' }}

should be sufficient

Done in PR #1105

@fgalan
Copy link
Member

fgalan commented Sep 14, 2021

@fgalan
Copy link
Member

fgalan commented Sep 14, 2021

In the https://github.com/telefonicaid/iotagent-ul/actions page we see a lib-update job:

imagen

So it seems it works!

@AlvaroVega AlvaroVega unpinned this issue Oct 5, 2021
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

No branches or pull requests

2 participants