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

Add build and test stage #37

Merged
merged 1 commit into from
Jun 21, 2024
Merged

Conversation

WStechura
Copy link
Contributor

No description provided.

@WStechura WStechura self-assigned this May 23, 2024
name: Build and test
on:
pull_request:
branches: [ "main" ]
Copy link
Contributor

Choose a reason for hiding this comment

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

why restricted only to main branch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no explaination for that. Should build be performed for every commit?

run: ansible-galaxy collection install dynatrace-oneagent*
- name: Running sanity test
run: pushd ~/.ansible/collections/ansible_collections/dynatrace/oneagent && ansible-test sanity && popd
- uses: actions/upload-artifact@v4
Copy link
Contributor

@jakubrak jakubrak May 24, 2024

Choose a reason for hiding this comment

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

publishing should be done at least as a separate step

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is the reason for that? I don't think putting it to separate job and create dependency between uploading and building just for a sake of separating them has any meaning

with:
python-version: '3.10'
- name: Installing dependencies
run: pip install ansible
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@WStechura WStechura force-pushed the add-github-action-for-sanity-check branch 3 times, most recently from a373c9d to e0c1e20 Compare June 6, 2024 07:24
@@ -0,0 +1,26 @@
# Copyright 2023 Dynatrace LLC
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Copyright 2023 Dynatrace LLC
# Copyright 2024 Dynatrace LLC

build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Copy link
Contributor

Choose a reason for hiding this comment

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

Please name the steps

name: Build, test and upload
on:
pull_request:
types: [ 'closed' ]
Copy link
Contributor

@jakubrak jakubrak Jun 6, 2024

Choose a reason for hiding this comment

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

why not just main branch? What is the difference?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So that the artifact is only published once the PR is closed

Copy link
Contributor

@jakubrak jakubrak Jun 14, 2024

Choose a reason for hiding this comment

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

What if PR is closed without merging to main branch? Shouldn't we trigger upload only on main branch?

workflow_dispatch:

env:
FILES_DIR: roles/oneagent/files
Copy link
Contributor

Choose a reason for hiding this comment

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

duplicated in build-and-test.yaml

steps:
- name: Download certificate
shell: bash
run: mkdir $FILES_DIR && wget https://ca.dynatrace.com/dt-root.cert.pem -P $FILES_DIR
Copy link
Contributor

Choose a reason for hiding this comment

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

It's worth to add $FILES_DIR directory creation as a separate step, because it may fail.

run: mkdir $FILES_DIR && wget https://ca.dynatrace.com/dt-root.cert.pem -P $FILES_DIR
- name: Building the collection
shell: bash
run: ansible-galaxy collection build .
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
run: ansible-galaxy collection build .
run: ansible-galaxy collection build . -vvv

ansible-galaxy collection build . does not generally provide much information.

- name: Download certificate
shell: bash
run: mkdir $FILES_DIR && wget https://ca.dynatrace.com/dt-root.cert.pem -P $FILES_DIR
- name: Building the collection
Copy link
Contributor

Choose a reason for hiding this comment

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

Please keep to the previously estabilished naming convention.
Building the collectionBuild the collection
Installing the collectionInstall the collection
etc.

name: Build and test
on:
pull_request:
branches: [ "*" ]
Copy link
Contributor

Choose a reason for hiding this comment

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

When you want to run a given workflow on all branches, you don't need to specify them. Following will work:

on:
  pull_request:
  push:
  workflow_dispatch:
  workflow_call:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In such scenario, push will work also on tags

workflow_call:

env:
FILES_DIR: roles/oneagent/files
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
FILES_DIR: roles/oneagent/files
CERTIFICATE_DIR: roles/oneagent/files

name: Build, test and upload
on:
pull_request:
branches: [ 'main' ]
Copy link
Contributor

@jakubrak jakubrak Jun 20, 2024

Choose a reason for hiding this comment

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

it should be:

  push:
    branches:
      - main

since we cannot open a PR on main branch

@WStechura WStechura force-pushed the add-github-action-for-sanity-check branch from 787b2c8 to 27ed92c Compare June 21, 2024 07:53
@WStechura WStechura merged commit 42b8298 into master Jun 21, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

3 participants