From 884d26b523358bf74dfd2514432fe429da26f428 Mon Sep 17 00:00:00 2001 From: David Hurley <34819526+david-hurley@users.noreply.github.com> Date: Mon, 16 Jun 2025 21:48:58 -0600 Subject: [PATCH 1/7] minor fixes --- docs/dagger/dagger-hackathon/README.md | 29 ++++++++++++-------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/docs/dagger/dagger-hackathon/README.md b/docs/dagger/dagger-hackathon/README.md index 9b1bf60c..d4b45fdc 100644 --- a/docs/dagger/dagger-hackathon/README.md +++ b/docs/dagger/dagger-hackathon/README.md @@ -2,7 +2,7 @@ Welcome to the Dagger hackathon hosted by the [CNCF](https://community.cncf.io/cloud-native-calgary/) and [Code to Cloud](https://www.codetocloud.io/)! By the end of this hack, you will have a good understanding of how to use Dagger and the various use cases it can help support. -πŸ‘€ Here’s the end-to-end flow: +**πŸ‘€ Here’s the end-to-end flow:** ![image](./assets/hack-overview.jpeg) @@ -16,7 +16,7 @@ Welcome to the Dagger hackathon hosted by the [CNCF](https://community.cncf.io/c 5️⃣ Dagger agent inspects the issue using smart tools πŸ” -6️⃣ A helpful comment appears on the PR πŸ’¬ +6️⃣ A suggested code change appears on the PR πŸ’¬ ## 🎯 Expected Outcomes @@ -116,7 +116,7 @@ The below steps will take you through making a breaking change to a file in our ``` and confirm it fails - Push the modified `addition.py` to your new feature branch -- In the GitHub UI, open a PR on the feature branch and compare to `main` +- In the GitHub UI, **open a PR** on the feature branch and compare to `main` (make sure to compare to `main` and not forked `main`) --- @@ -125,21 +125,16 @@ The below steps will take you through making a breaking change to a file in our spongebob - Rename `docs/dagger/dagger-hackathon/.env-example` to `.env` -- Populate the placeholder keys with real values (we will provide for Hackathon day) +- Populate the placeholder keys with real values (we will provide the full API key during the hackathon) + - `OPENAI_API_KEY`: FT0Dd0iIglkzGbizOMUp79k0Frea7neDtVXRhFZ5m39CJJJcdfxFJQQJ99BEACYeBjFXJ3w3AAABACO + - `OPENAI_BASE_URL`: https://vdfvdf.openai.azure.com/ - Create environment variables for `GITHUB_TOKEN` and `AZURE_OPENAI_API_KEY` - A GitHub Token can be created in GitHub under Settings β†’ Developer Settings β†’ Create a classic token + A GitHub Token can be created in GitHub under Settings β†’ Developer Settings β†’ Create a classic token (you must have repo and workflow scopes) Example: ```bash export GITHUB_TOKEN="XXX" ``` -The Azure OpenAI details can be found below: - -- Azure OpenAI API Key: FT0Dd0iIglkzGbizOMUp79k0Frea7neDtVXRhFZ5m39CJJJcdfxFJQQJ99BEACYeBjFXJ3w3AAABACO -- Azure OpenAI Endpoint: https://vdfvdf.openai.azure.com/ - -> **Note:** The full API key will be provided during the hackathon. - -- Put in your values and run in CLI: +- Fill in values for `github_branch`, `github_repo`, and `azure_openai_endpoint` (same as `OPENAI_BASE_URL`) and run in CLI: ```bash dagger call \ --source="." \ @@ -192,8 +187,8 @@ Being able to navigate and explore logs in Dagger Cloud is a great skill to have ### βœ… Step 8: Trigger GitHub Action -- Delete the comment the Agent left on the PR in Step 6 -- [Create GitHub secrets](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository) for everything in `.env` and name them `DAGGER_HACKATHON_GITHUB_TOKEN` and `OPENAI_API_KEY` for the GitHub token and Azure OpenAI API key respectively. +- Delete any comments the Agent left on the PR in Step 6 +- [Create GitHub secrets](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository) for `DAGGER_CLOUD_TOKEN`, `DAGGER_HACKATHON_GITHUB_TOKEN` (what was `GITHUB_TOKEN`), and `OPENAI_API_KEY`. - Make sure to update your GitHub Action to trigger on a pull request instead of a manual trigger. Update the trigger from this: @@ -211,7 +206,9 @@ on: types: [opened, synchronize, reopened] ``` -- Push your changes to Git and navigate back to your forked repo to see the GitHub Action running +- Push your changes to Git + +- Now break the code in a different way in `addition.py` and push those changes. You should see a action running. ![image](./assets/run_unit_tests.png) From 017e6be32f8205dc2a2b2ec43135b2173b25fc77 Mon Sep 17 00:00:00 2001 From: David Hurley <34819526+david-hurley@users.noreply.github.com> Date: Mon, 16 Jun 2025 21:49:51 -0600 Subject: [PATCH 2/7] remove array indexer --- .../dagger-hackathon-pipeline/src/dagger_hackathon/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dagger/dagger-hackathon/dagger-hackathon-pipeline/src/dagger_hackathon/main.py b/docs/dagger/dagger-hackathon/dagger-hackathon-pipeline/src/dagger_hackathon/main.py index af90dd98..0c892f29 100644 --- a/docs/dagger/dagger-hackathon/dagger-hackathon-pipeline/src/dagger_hackathon/main.py +++ b/docs/dagger/dagger-hackathon/dagger-hackathon-pipeline/src/dagger_hackathon/main.py @@ -67,7 +67,7 @@ async def GetPrMetadata(self) -> PrMetadataResult: "--head", f"{self.github_branch}", "--limit", "1", "--json", "number", - "--jq", ".[0].number", + "--jq", ".[].number", "--repo", f"{self.github_repo}" ]) .stdout() From e244252a17f9e1fd9be10aed7b2828563e4742c8 Mon Sep 17 00:00:00 2001 From: David Hurley <34819526+david-hurley@users.noreply.github.com> Date: Mon, 16 Jun 2025 22:02:14 -0600 Subject: [PATCH 3/7] Update dagger_hackathon.yml --- .github/workflows/dagger_hackathon.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/dagger_hackathon.yml b/.github/workflows/dagger_hackathon.yml index 3df1dac4..ff4986ff 100644 --- a/.github/workflows/dagger_hackathon.yml +++ b/.github/workflows/dagger_hackathon.yml @@ -1,7 +1,9 @@ name: dagger_hackathon on: - workflow_dispatch: + pull_request: + branches: [main] + types: [opened, synchronize, reopened] jobs: dagger-run-unit-tests: @@ -11,6 +13,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.DAGGER_HACKATHON_GITHUB_TOKEN }} OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} CURRENT_BRANCH: ${{ github.head_ref }} + CURRENT_REPO: ${{ github.repository }} + DAGGER_CLOUD_TOKEN: ${{ secrets.DAGGER_CLOUD_TOKEN }} steps: - name: Checkout repo @@ -29,21 +33,19 @@ jobs: OPENAI_MODEL=gpt-4o OPENAI_API_KEY=${OPENAI_API_KEY} OPENAI_AZURE_VERSION=2024-12-01-preview - GITHUB_TOKEN=${GITHUB_TOKEN} EOF - name: Dagger Run Unit Tests working-directory: docs/dagger/dagger-hackathon/ - env: - DAGGER_SECRET_GITHUB_TOKEN: ${{ secrets.DAGGER_HACKATHON_GITHUB_TOKEN }} run: | export AZURE_OPENAI_API_KEY="${OPENAI_API_KEY}" - export AZURE_OPENAI_ENDPOINT="https://vdfvdf.openai.azure.com/" + export GITHUB_TOKEN="${GITHUB_TOKEN}" + export DAGGER_CLOUD_TOKEN="${DAGGER_CLOUD_TOKEN}" dagger call \ --source="." \ --github_branch="${CURRENT_BRANCH}" \ - --github_repo="codetocloudorg/platform-engineering" \ - --github_token=DAGGER_SECRET_GITHUB_TOKEN \ - --azure_api_key="OPENAI_API_KEY" \ - --azure_endpoint="https://vdfvdf.openai.azure.com/" \ + --github_repo="${CURRENT_REPO}" \ + --github_token=GITHUB_TOKEN \ + --azure_openai_api_key=AZURE_OPENAI_API_KEY \ + --azure_openai_endpoint="https://vdfvdf.openai.azure.com/" \ fix-my-tests-agent From 1d1937841e6a2fce4deb27986ccb762e473c2ab6 Mon Sep 17 00:00:00 2001 From: David Hurley <34819526+david-hurley@users.noreply.github.com> Date: Mon, 16 Jun 2025 22:03:18 -0600 Subject: [PATCH 4/7] change to workflow trigger --- .github/workflows/dagger_hackathon.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/dagger_hackathon.yml b/.github/workflows/dagger_hackathon.yml index ff4986ff..e1a00dc0 100644 --- a/.github/workflows/dagger_hackathon.yml +++ b/.github/workflows/dagger_hackathon.yml @@ -1,9 +1,7 @@ name: dagger_hackathon on: - pull_request: - branches: [main] - types: [opened, synchronize, reopened] + workflow_dispatch: jobs: dagger-run-unit-tests: From c5eabb8f8d4ce929eaca2bde90efe21088cc012a Mon Sep 17 00:00:00 2001 From: David Hurley <34819526+david-hurley@users.noreply.github.com> Date: Mon, 16 Jun 2025 22:05:44 -0600 Subject: [PATCH 5/7] dry up workflow file --- .github/workflows/dagger_hackathon.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dagger_hackathon.yml b/.github/workflows/dagger_hackathon.yml index e1a00dc0..f86d97fd 100644 --- a/.github/workflows/dagger_hackathon.yml +++ b/.github/workflows/dagger_hackathon.yml @@ -1,7 +1,9 @@ name: dagger_hackathon on: - workflow_dispatch: + pull_request: + branches: [main] + types: [opened, synchronize, reopened] jobs: dagger-run-unit-tests: @@ -13,6 +15,7 @@ jobs: CURRENT_BRANCH: ${{ github.head_ref }} CURRENT_REPO: ${{ github.repository }} DAGGER_CLOUD_TOKEN: ${{ secrets.DAGGER_CLOUD_TOKEN }} + AZURE_OPENAI_ENDPOINT: https://vdfvdf.openai.azure.com/ steps: - name: Checkout repo @@ -27,7 +30,7 @@ jobs: working-directory: docs/dagger/dagger-hackathon/ run: | cat < .env - OPENAI_BASE_URL=https://vdfvdf.openai.azure.com/ + OPENAI_BASE_URL=${AZURE_OPENAI_ENDPOINT} OPENAI_MODEL=gpt-4o OPENAI_API_KEY=${OPENAI_API_KEY} OPENAI_AZURE_VERSION=2024-12-01-preview @@ -45,5 +48,5 @@ jobs: --github_repo="${CURRENT_REPO}" \ --github_token=GITHUB_TOKEN \ --azure_openai_api_key=AZURE_OPENAI_API_KEY \ - --azure_openai_endpoint="https://vdfvdf.openai.azure.com/" \ + --azure_openai_endpoint="${AZURE_OPENAI_ENDPOINT}" \ fix-my-tests-agent From 32701da934757130ad36ec37024a0ca8715f6f10 Mon Sep 17 00:00:00 2001 From: David Hurley <34819526+david-hurley@users.noreply.github.com> Date: Mon, 16 Jun 2025 22:06:58 -0600 Subject: [PATCH 6/7] update trigger --- .github/workflows/dagger_hackathon.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/dagger_hackathon.yml b/.github/workflows/dagger_hackathon.yml index f86d97fd..7b13364d 100644 --- a/.github/workflows/dagger_hackathon.yml +++ b/.github/workflows/dagger_hackathon.yml @@ -1,9 +1,7 @@ name: dagger_hackathon on: - pull_request: - branches: [main] - types: [opened, synchronize, reopened] + workflow_dispatch: jobs: dagger-run-unit-tests: From a63cc41c7b2fa6c7e64f28a5e0a15dddb6c145c2 Mon Sep 17 00:00:00 2001 From: David Hurley <34819526+david-hurley@users.noreply.github.com> Date: Mon, 16 Jun 2025 22:07:49 -0600 Subject: [PATCH 7/7] final refactor --- .github/workflows/dagger_hackathon.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/dagger_hackathon.yml b/.github/workflows/dagger_hackathon.yml index 7b13364d..2cb68cd9 100644 --- a/.github/workflows/dagger_hackathon.yml +++ b/.github/workflows/dagger_hackathon.yml @@ -48,3 +48,4 @@ jobs: --azure_openai_api_key=AZURE_OPENAI_API_KEY \ --azure_openai_endpoint="${AZURE_OPENAI_ENDPOINT}" \ fix-my-tests-agent +