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

Test paas-app-charmer changes in discourse-gateway #330

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f64f95b
Add tmate to see how this thing works
javierdelapuente Mar 27, 2024
156fa3b
Use branch for paas-app-charmer in discourse-gatekeeper
javierdelapuente Mar 27, 2024
c7d7cd4
Let's try a matrix to see if this works
javierdelapuente Mar 27, 2024
5873d57
matrix strategy for e2e conflicts
javierdelapuente Mar 27, 2024
cbaf67a
Put max-parallel in its correct place...
javierdelapuente Mar 27, 2024
044ab96
Add tmate again to see what is there
javierdelapuente Mar 27, 2024
bf714c6
Let's see how it fails
javierdelapuente Mar 27, 2024
60aaa28
create charmcraft.yaml in bash
javierdelapuente Mar 27, 2024
9359e34
logging
javierdelapuente Mar 27, 2024
3e4008c
learning shell scripting in github
javierdelapuente Mar 27, 2024
c6a0357
Fix broken doc link
javierdelapuente Mar 27, 2024
9033c6a
tmate where it is failing
javierdelapuente Mar 27, 2024
d3672e6
print initial branch
javierdelapuente Mar 27, 2024
bbb9bbd
remote metadata.yaml
javierdelapuente Mar 27, 2024
c1856c8
commit charmcraft.yaml
javierdelapuente Mar 27, 2024
e07a53d
Update all gatekeeper code.
javierdelapuente Mar 27, 2024
40e8054
So all runs and we see if I broke something...
javierdelapuente Mar 27, 2024
c0e6dcf
new argument charm-dir for tests/e2e/migrate.py
javierdelapuente Mar 27, 2024
6be83db
Use as e2e setup paas-app-charmer branch
javierdelapuente Mar 27, 2024
7df61ba
Pass charm_dir directory
javierdelapuente Mar 27, 2024
e21408c
Add charm_dir to migrate.py
javierdelapuente Mar 27, 2024
11ae2cd
Let's see if this gets the file...
javierdelapuente Mar 27, 2024
5f1096c
run more tests to see if they work...
javierdelapuente Mar 27, 2024
7eb342b
Let's see how far we get
javierdelapuente Mar 27, 2024
12b30ae
Only create if it does not exists
javierdelapuente Mar 27, 2024
80e7762
Fix linting
javierdelapuente Mar 27, 2024
ac0e77a
changa metadata.yaml instead of charmcraft.yaml
javierdelapuente Mar 27, 2024
063a95d
Add missing charm_dir parameters
javierdelapuente Mar 27, 2024
b1c7545
git rm instead of just rm to delete previous metadata.yaml
javierdelapuente Mar 27, 2024
3d2e53e
Do not print all commands to terminal
javierdelapuente Apr 1, 2024
42bae01
Remeve unneeded commands and reword comments
javierdelapuente Apr 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 35 additions & 11 deletions .github/workflows/e2e_conflicts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ jobs:
concurrency: e2e-tests
permissions: write-all
runs-on: ubuntu-22.04
strategy:
max-parallel: 1
matrix:
charm-dir:
-
- charm
Comment on lines +15 to +20
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm hesitant to add complexity like this to the e2e tests, especially since we have to write them in bash and that when it is the charm case we also actually change from metadata to charmcraft. 2 options i can think of:

  1. Add another stage to the tests which change from metadata to charmcraft and inside a directory
  2. Add a separate test file

I would also run this in reconclide rather than conflict since we're not really testing a conflict.

Probably we can go with adding another job to reconcile which has 1 documentation file inside a directory and making use of charmcraft rather than metadata and just run the create action on that and leave it at that

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would also run this in reconclide rather than conflict since we're not really testing a conflict.

I'm fine with either, but if we go with 1) I would put this in the conflict tests. End2End tests test a number of things and integrations beside conflicts, so that should be totally fine. The reason why I would not put this in the reconcile is that reconcile is the test where we do update production Discourse (to make sure the integration works correctly) which we don't run in scheduled fashion to avoid cluttering Discourse too much. Anything we put there is somewhat less checked.

So by default, we should place more things on pulling tests (such as the conflict ones) that we run often and don't clutter Discourse.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good, perhaps we can rename this file

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I'm happy with this, I also find it somewhat confusing. We could just go for "Pulling Test" and "Pushing Test". If we will start splitting tests further we could revisit this

steps:
# Each job has to have this configuration because secrets can be passed through the output of
# another job
Expand All @@ -35,7 +41,20 @@ jobs:
- name: Prepare stage
id: prepare-stage
run: |
PYTHONPATH=$(pwd) python3 tests/e2e/migrate.py --action prepare --github-token ${{ secrets.GITHUB_TOKEN }} '${{ steps.configuration.outputs.discourse }}'
PYTHONPATH=$(pwd) python3 tests/e2e/migrate.py --charm-dir "./${{ matrix.charm-dir }}" --action prepare --github-token ${{ secrets.GITHUB_TOKEN }} '${{ steps.configuration.outputs.discourse }}'

if [ ! -d "./${{ matrix.charm-dir }}" ]; then
# For this case, charm-dir not the base directory, use charmcraft.yaml instead of metadata.yaml.
mkdir -p "./${{ matrix.charm-dir }}"
echo "name: $(echo ${{ github.repository }} | sed 's:.*/::')-test" > ./${{ matrix.charm-dir }}/charmcraft.yaml
echo "links:" >> ./${{ matrix.charm-dir }}/charmcraft.yaml
echo " documentation: https://discourse.charmhub.io/t/charmed-mongodb-k8s-documentation/9731" >> ./${{ matrix.charm-dir }}/charmcraft.yaml
git rm metadata.yaml
git rm charmcraft.yaml
git add charm/charmcraft.yaml
git commit -m "Use charmcraft.yaml instead of metadata.yaml"
git push
fi

echo $(git log | head -n 1)

Expand All @@ -47,7 +66,7 @@ jobs:

- name: Import Documentation
id: import
uses: canonical/discourse-gatekeeper@main
uses: canonical/discourse-gatekeeper@ISD-1620-NetBox-Build-all-missing-documentation-required-for-a-production-charm
with:
discourse_host: discourse.charmhub.io
discourse_api_username: ${{ secrets.DISCOURSE_API_USERNAME }}
Expand All @@ -56,13 +75,14 @@ jobs:
dry_run: true
base_branch: "tests/base"
commit_sha: ${{ steps.prepare-stage.outputs.commit_sha }}
charm_dir: ${{ matrix.charm-dir }}

- name: Check creation
run: |
echo '${{ steps.import.outputs.pr_link }}'
echo '${{ steps.import.outputs.pr_action }}'
echo $(git log | head -n 1)
PYTHONPATH=$(pwd) python3 tests/e2e/migrate.py --action check-pull-request --github-token ${{ secrets.GITHUB_TOKEN }} '${{ steps.configuration.outputs.discourse }}'
PYTHONPATH=$(pwd) python3 tests/e2e/migrate.py --charm-dir "./${{ matrix.charm-dir }}" --action check-pull-request --github-token ${{ secrets.GITHUB_TOKEN }} '${{ steps.configuration.outputs.discourse }}'
echo $(git log | head -n 1)

echo "Tags"
Expand All @@ -87,19 +107,20 @@ jobs:

- name: Release Pipeline Documentation
id: release-import
uses: canonical/discourse-gatekeeper@main
uses: canonical/discourse-gatekeeper@ISD-1620-NetBox-Build-all-missing-documentation-required-for-a-production-charm
with:
discourse_host: discourse.charmhub.io
discourse_api_username: ${{ secrets.DISCOURSE_API_USERNAME }}
discourse_api_key: ${{ secrets.DISCOURSE_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
base_branch: "tests/base"
commit_sha: ${{ steps.merge-import.outputs.commit_sha }}
charm_dir: ${{ matrix.charm-dir }}

- name: Create conflict
id: create-conflict
run: |
PYTHONPATH=$(pwd) python3 tests/e2e/migrate.py --action create-conflict --github-token ${{ secrets.GITHUB_TOKEN }} '${{ steps.configuration.outputs.discourse }}'
PYTHONPATH=$(pwd) python3 tests/e2e/migrate.py --charm-dir "./${{ matrix.charm-dir }}" --action create-conflict --github-token ${{ secrets.GITHUB_TOKEN }} '${{ steps.configuration.outputs.discourse }}'

git status

Expand All @@ -109,7 +130,7 @@ jobs:
- name: Raise Conflict in PR
id: conflict
continue-on-error: true
uses: canonical/discourse-gatekeeper@main
uses: canonical/discourse-gatekeeper@ISD-1620-NetBox-Build-all-missing-documentation-required-for-a-production-charm
with:
discourse_host: discourse.charmhub.io
discourse_api_username: ${{ secrets.DISCOURSE_API_USERNAME }}
Expand All @@ -118,20 +139,21 @@ jobs:
dry_run: true
base_branch: "tests/base"
commit_sha: ${{ steps.create-conflict.outputs.commit_sha }}
charm_dir: ${{ matrix.charm-dir }}

- name: Resolve conflict
id: resolve-conflict
run: |
if [ ${{ steps.conflict.outcome }} != "failure" ]; then exit 1; fi

PYTHONPATH=$(pwd) python3 tests/e2e/migrate.py --action resolve-conflict --github-token ${{ secrets.GITHUB_TOKEN }} '${{ steps.configuration.outputs.discourse }}'
PYTHONPATH=$(pwd) python3 tests/e2e/migrate.py --charm-dir "./${{ matrix.charm-dir }}" --action resolve-conflict --github-token ${{ secrets.GITHUB_TOKEN }} '${{ steps.configuration.outputs.discourse }}'

COMMIT_SHA=$(git log | head -n 1 | sed -En "s/commit\ //p")
echo "commit_sha=$COMMIT_SHA" >> "$GITHUB_OUTPUT"

- name: Run Gatekeeper
id: feature-check
uses: canonical/discourse-gatekeeper@main
uses: canonical/discourse-gatekeeper@ISD-1620-NetBox-Build-all-missing-documentation-required-for-a-production-charm
with:
discourse_host: discourse.charmhub.io
discourse_api_username: ${{ secrets.DISCOURSE_API_USERNAME }}
Expand All @@ -140,30 +162,32 @@ jobs:
dry_run: true
base_branch: "tests/base"
commit_sha: ${{ steps.resolve-conflict.outputs.commit_sha }}
charm_dir: ${{ matrix.charm-dir }}

- name: Merge Feature Branch
id: merge-feature
run: |
if [ ${{ steps.feature-check.outcome }} != "success" ]; then exit 1; fi
if [ ${{ steps.feature-check.outputs.pr_action }} != "opened" ]; then exit 1; fi

PYTHONPATH=$(pwd) python3 tests/e2e/migrate.py --action merge-feature --github-token ${{ secrets.GITHUB_TOKEN }} '${{ steps.configuration.outputs.discourse }}'
PYTHONPATH=$(pwd) python3 tests/e2e/migrate.py --charm-dir "./${{ matrix.charm-dir }}" --action merge-feature --github-token ${{ secrets.GITHUB_TOKEN }} '${{ steps.configuration.outputs.discourse }}'
COMMIT_SHA=$(git log | head -n 1 | sed -En "s/commit\ //p")
echo "commit_sha=$COMMIT_SHA" >> "$GITHUB_OUTPUT"

- name: Release Feature
id: release-feature
uses: canonical/discourse-gatekeeper@main
uses: canonical/discourse-gatekeeper@ISD-1620-NetBox-Build-all-missing-documentation-required-for-a-production-charm
with:
discourse_host: discourse.charmhub.io
discourse_api_username: ${{ secrets.DISCOURSE_API_USERNAME }}
discourse_api_key: ${{ secrets.DISCOURSE_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
base_branch: "tests/base"
commit_sha: ${{ steps.merge-feature.outputs.commit_sha }}
charm_dir: ${{ matrix.charm-dir }}

- name: Cleanup
run: |
if [ ${{ steps.release-feature.outputs.pr_action }} != "closed" ]; then exit 1; fi

PYTHONPATH=$(pwd) python3 tests/e2e/migrate.py --action cleanup --github-token ${{ secrets.GITHUB_TOKEN }} '${{ steps.configuration.outputs.discourse }}'
PYTHONPATH=$(pwd) python3 tests/e2e/migrate.py --charm-dir "./${{ matrix.charm-dir }}" --action cleanup --github-token ${{ secrets.GITHUB_TOKEN }} '${{ steps.configuration.outputs.discourse }}'
Loading
Loading