diff --git a/.github/workflows/dagger_hackathon.yml b/.github/workflows/dagger_hackathon.yml index 3df1dac4..2cb68cd9 100644 --- a/.github/workflows/dagger_hackathon.yml +++ b/.github/workflows/dagger_hackathon.yml @@ -11,6 +11,9 @@ 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 }} + AZURE_OPENAI_ENDPOINT: https://vdfvdf.openai.azure.com/ steps: - name: Checkout repo @@ -25,25 +28,24 @@ 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 - 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="${AZURE_OPENAI_ENDPOINT}" \ fix-my-tests-agent + 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) 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()