From c9b22e8c22d3cc23089ff42086949fdf8586aff0 Mon Sep 17 00:00:00 2001 From: dberenbaum Date: Mon, 25 Sep 2023 11:31:04 -0400 Subject: [PATCH 01/14] add gha to deploy example-get-started --- .../workflows/example-get-started-deploy.yaml | 61 +++++++++++++++++++ .../workflows/example-get-started-test.yaml | 2 + README.md | 10 ++- example-get-started/README.md | 4 +- 4 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/example-get-started-deploy.yaml diff --git a/.github/workflows/example-get-started-deploy.yaml b/.github/workflows/example-get-started-deploy.yaml new file mode 100644 index 00000000..8f6a9612 --- /dev/null +++ b/.github/workflows/example-get-started-deploy.yaml @@ -0,0 +1,61 @@ +name: example-get-started deploy +on: + push: + paths: + - example-get-started/** + branches: + - master + workflow_dispatch: +permissions: + contents: write + id-token: write + pull-requests: write +jobs: + test: + runs-on: ubuntu-latest + environment: aws + steps: + - name: Checkout repo + uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + cache: 'pip' + - uses: aws-actions/configure-aws-credentials@v2 + with: + aws-region: us-east-2 + role-to-assume: ${{ vars.AWS_SANDBOX_ROLE }} + role-duration-seconds: 43200 + - uses: iterative/setup-dvc@v1 + - name: Generate repo + run: | + pip install virtualenv + cd example-get-started + ./generate.sh true + - name: Deploy repo + env: + REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # add remote + cd build/example-get-started + git remote add origin git@github.com:iterative/example-get-started.git + # close open PRs + gh pr close try-large-dataset + gh pr close tune-hyperparams + # force push branches + git push --force origin main + git push --force origin try-large-dataset + git push --force origin tune-hyperparams + # we push git tags one by one for Studio to receive webhooks: + git tag --sort=creatordate | xargs -n 1 git push --force origin + # push exp refs + dvc exp remove -A -g origin + dvc exp push origin -A + # create PRs + gh pr create -t "Try 40K dataset (4x data)" \ + -b "We are trying here a large dataset, since the smaller one looks unstable" \ + -B main -H try-large-dataset + gh pr create -t "Run experiments tuning random forest params" \ + -b "Better RF split and number of estimators based on small grid search." \ + -B main -H tune-hyperparams diff --git a/.github/workflows/example-get-started-test.yaml b/.github/workflows/example-get-started-test.yaml index f7fe9a82..4c0b9d35 100644 --- a/.github/workflows/example-get-started-test.yaml +++ b/.github/workflows/example-get-started-test.yaml @@ -4,6 +4,8 @@ on: paths: - example-get-started/** workflow_dispatch: + schedule: + - cron: '0 0 * * 1' permissions: contents: read id-token: write diff --git a/README.md b/README.md index 5df0d4bf..ba354d53 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,14 @@ $ ./deploy.sh ### example-get-started -You only directly need `generate.sh`. `deploy.sh` is a helper script run within -`generate.sh`. +There are 2 GitHub Actions set up to test and deploy the project: + +- [test](.github/workflows/example-get-started-test.yaml) +- [deploy](.github/workflows/example-get-started-deploy.yaml) + +These will automatically test and deploy the project. If you need to run the project +locally/manually, you only directly need `generate.sh`. `deploy.sh` is a helper script +run within `generate.sh`. - `generate.sh`: Generates the `example-get-started` DVC project from scratch. diff --git a/example-get-started/README.md b/example-get-started/README.md index baf03730..2b3f0f6c 100644 --- a/example-get-started/README.md +++ b/example-get-started/README.md @@ -24,10 +24,10 @@ For the basic use case (docs and Studio demo), use the command below. ``` If change source code, to publish it on S3 (needed for the get started tutorial) -pass `true` to the command. It's needed when you ready to publish it. +pass `prod` to the command. It's needed when you ready to publish it. ```shell -./generate.sh true +./generate.sh prod ``` The repo generated in `build/example-get-started` is intended to be published on From e6ece14f9ad1078322cb04f343916d150f9816c5 Mon Sep 17 00:00:00 2001 From: dberenbaum Date: Mon, 25 Sep 2023 13:06:41 -0400 Subject: [PATCH 02/14] drop existing refs --- .github/workflows/example-get-started-deploy.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/example-get-started-deploy.yaml b/.github/workflows/example-get-started-deploy.yaml index 8f6a9612..f02d6211 100644 --- a/.github/workflows/example-get-started-deploy.yaml +++ b/.github/workflows/example-get-started-deploy.yaml @@ -43,6 +43,8 @@ jobs: # close open PRs gh pr close try-large-dataset gh pr close tune-hyperparams + # drop existing refs + git ls-remote origin | awk '{print $2}' | xargs -n 1 git push --delete origin || true # force push branches git push --force origin main git push --force origin try-large-dataset @@ -50,7 +52,6 @@ jobs: # we push git tags one by one for Studio to receive webhooks: git tag --sort=creatordate | xargs -n 1 git push --force origin # push exp refs - dvc exp remove -A -g origin dvc exp push origin -A # create PRs gh pr create -t "Try 40K dataset (4x data)" \ From ec5d15bd0d023889fbbdb998938d8ca68b15d0fc Mon Sep 17 00:00:00 2001 From: dberenbaum Date: Mon, 25 Sep 2023 13:20:34 -0400 Subject: [PATCH 03/14] debugging deploy workflow --- .github/workflows/example-get-started-deploy.yaml | 2 +- .github/workflows/example-get-started-test.yaml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/example-get-started-deploy.yaml b/.github/workflows/example-get-started-deploy.yaml index f02d6211..d3526857 100644 --- a/.github/workflows/example-get-started-deploy.yaml +++ b/.github/workflows/example-get-started-deploy.yaml @@ -38,7 +38,7 @@ jobs: REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | # add remote - cd build/example-get-started + cd example-get-started/build/example-get-started git remote add origin git@github.com:iterative/example-get-started.git # close open PRs gh pr close try-large-dataset diff --git a/.github/workflows/example-get-started-test.yaml b/.github/workflows/example-get-started-test.yaml index 4c0b9d35..ffd9b862 100644 --- a/.github/workflows/example-get-started-test.yaml +++ b/.github/workflows/example-get-started-test.yaml @@ -3,6 +3,9 @@ on: push: paths: - example-get-started/** + branches: + - '**' # matches every branch + - '!master' # excludes master workflow_dispatch: schedule: - cron: '0 0 * * 1' From 6bff00e3b75f178c14957276fd7d3a00d828aaf8 Mon Sep 17 00:00:00 2001 From: dberenbaum Date: Mon, 25 Sep 2023 13:27:04 -0400 Subject: [PATCH 04/14] fix token for gh cli --- .github/workflows/example-get-started-deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/example-get-started-deploy.yaml b/.github/workflows/example-get-started-deploy.yaml index d3526857..a67a58d6 100644 --- a/.github/workflows/example-get-started-deploy.yaml +++ b/.github/workflows/example-get-started-deploy.yaml @@ -35,7 +35,7 @@ jobs: ./generate.sh true - name: Deploy repo env: - REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | # add remote cd example-get-started/build/example-get-started From 6822d5b828c1222b7d514b2d306f5b8f8bdc9f5c Mon Sep 17 00:00:00 2001 From: dberenbaum Date: Mon, 25 Sep 2023 13:38:04 -0400 Subject: [PATCH 05/14] write-all permissions --- .github/workflows/example-get-started-deploy.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/example-get-started-deploy.yaml b/.github/workflows/example-get-started-deploy.yaml index a67a58d6..0aa63fcd 100644 --- a/.github/workflows/example-get-started-deploy.yaml +++ b/.github/workflows/example-get-started-deploy.yaml @@ -6,10 +6,7 @@ on: branches: - master workflow_dispatch: -permissions: - contents: write - id-token: write - pull-requests: write +permissions: write-all jobs: test: runs-on: ubuntu-latest From f4fd0d9057e13c7aed38a456c0da253e312c83cc Mon Sep 17 00:00:00 2001 From: dberenbaum Date: Mon, 25 Sep 2023 13:47:18 -0400 Subject: [PATCH 06/14] debugging permissions --- .github/workflows/example-get-started-deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/example-get-started-deploy.yaml b/.github/workflows/example-get-started-deploy.yaml index 0aa63fcd..ded1fbbe 100644 --- a/.github/workflows/example-get-started-deploy.yaml +++ b/.github/workflows/example-get-started-deploy.yaml @@ -32,7 +32,7 @@ jobs: ./generate.sh true - name: Deploy repo env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} run: | # add remote cd example-get-started/build/example-get-started From 0eac23054729cd5f7c7ad5183dea9d705c68ccd0 Mon Sep 17 00:00:00 2001 From: dberenbaum Date: Mon, 25 Sep 2023 13:56:48 -0400 Subject: [PATCH 07/14] use http remote --- .github/workflows/example-get-started-deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/example-get-started-deploy.yaml b/.github/workflows/example-get-started-deploy.yaml index ded1fbbe..5bdbcd36 100644 --- a/.github/workflows/example-get-started-deploy.yaml +++ b/.github/workflows/example-get-started-deploy.yaml @@ -36,7 +36,7 @@ jobs: run: | # add remote cd example-get-started/build/example-get-started - git remote add origin git@github.com:iterative/example-get-started.git + git remote add origin https://github.com/iterative/example-get-started.git # close open PRs gh pr close try-large-dataset gh pr close tune-hyperparams From 957c0943f727c951c4b67cbb9bc1208b0ffebac3 Mon Sep 17 00:00:00 2001 From: dberenbaum Date: Mon, 25 Sep 2023 14:06:57 -0400 Subject: [PATCH 08/14] debug tokens --- .github/workflows/example-get-started-deploy.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/example-get-started-deploy.yaml b/.github/workflows/example-get-started-deploy.yaml index 5bdbcd36..6d4f7213 100644 --- a/.github/workflows/example-get-started-deploy.yaml +++ b/.github/workflows/example-get-started-deploy.yaml @@ -33,6 +33,7 @@ jobs: - name: Deploy repo env: GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | # add remote cd example-get-started/build/example-get-started From 5a2a8f9b792d4bef6bf96431653883ef8fcbe52e Mon Sep 17 00:00:00 2001 From: dberenbaum Date: Mon, 25 Sep 2023 14:23:06 -0400 Subject: [PATCH 09/14] use cml to configure git --- .github/workflows/example-get-started-deploy.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/example-get-started-deploy.yaml b/.github/workflows/example-get-started-deploy.yaml index 6d4f7213..c86f88d2 100644 --- a/.github/workflows/example-get-started-deploy.yaml +++ b/.github/workflows/example-get-started-deploy.yaml @@ -24,7 +24,8 @@ jobs: aws-region: us-east-2 role-to-assume: ${{ vars.AWS_SANDBOX_ROLE }} role-duration-seconds: 43200 - - uses: iterative/setup-dvc@v1 + - uses: iterative/setup-cml@v1 + run: cml ci --unshallow - name: Generate repo run: | pip install virtualenv @@ -33,7 +34,6 @@ jobs: - name: Deploy repo env: GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | # add remote cd example-get-started/build/example-get-started From 12f27ad46745440d58adcd49b6798fd7edd728d4 Mon Sep 17 00:00:00 2001 From: dberenbaum Date: Mon, 25 Sep 2023 14:24:02 -0400 Subject: [PATCH 10/14] use cml to configure git --- .github/workflows/example-get-started-deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/example-get-started-deploy.yaml b/.github/workflows/example-get-started-deploy.yaml index c86f88d2..17987976 100644 --- a/.github/workflows/example-get-started-deploy.yaml +++ b/.github/workflows/example-get-started-deploy.yaml @@ -25,7 +25,6 @@ jobs: role-to-assume: ${{ vars.AWS_SANDBOX_ROLE }} role-duration-seconds: 43200 - uses: iterative/setup-cml@v1 - run: cml ci --unshallow - name: Generate repo run: | pip install virtualenv @@ -37,6 +36,7 @@ jobs: run: | # add remote cd example-get-started/build/example-get-started + cml ci --unshallow git remote add origin https://github.com/iterative/example-get-started.git # close open PRs gh pr close try-large-dataset From 6142060c3c358ec44525ad2a75622ade6fd7fb00 Mon Sep 17 00:00:00 2001 From: dberenbaum Date: Mon, 25 Sep 2023 14:34:58 -0400 Subject: [PATCH 11/14] debug git config --- .github/workflows/example-get-started-deploy.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/example-get-started-deploy.yaml b/.github/workflows/example-get-started-deploy.yaml index 17987976..9c24ae93 100644 --- a/.github/workflows/example-get-started-deploy.yaml +++ b/.github/workflows/example-get-started-deploy.yaml @@ -24,9 +24,11 @@ jobs: aws-region: us-east-2 role-to-assume: ${{ vars.AWS_SANDBOX_ROLE }} role-duration-seconds: 43200 - - uses: iterative/setup-cml@v1 + - uses: iterative/setup-dvc@v1 - name: Generate repo run: | + git config --global user.name dberenbaum + git config --global user.email dave@iterative.ai pip install virtualenv cd example-get-started ./generate.sh true @@ -36,7 +38,6 @@ jobs: run: | # add remote cd example-get-started/build/example-get-started - cml ci --unshallow git remote add origin https://github.com/iterative/example-get-started.git # close open PRs gh pr close try-large-dataset From b3b6a29eac7ebb3efce439ab42d9566ea2207aa9 Mon Sep 17 00:00:00 2001 From: dberenbaum Date: Mon, 25 Sep 2023 14:48:37 -0400 Subject: [PATCH 12/14] debug git config --- .github/workflows/example-get-started-deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/example-get-started-deploy.yaml b/.github/workflows/example-get-started-deploy.yaml index 9c24ae93..76c4da4d 100644 --- a/.github/workflows/example-get-started-deploy.yaml +++ b/.github/workflows/example-get-started-deploy.yaml @@ -38,7 +38,7 @@ jobs: run: | # add remote cd example-get-started/build/example-get-started - git remote add origin https://github.com/iterative/example-get-started.git + git remote add origin https://${{ secrets.GITHUB_TOKEN }}@github.com/iterative/example-get-started.git # close open PRs gh pr close try-large-dataset gh pr close tune-hyperparams From 63fc48ec6ef01a48bc894780a9b2d48c5f9341e9 Mon Sep 17 00:00:00 2001 From: dberenbaum Date: Mon, 25 Sep 2023 15:04:41 -0400 Subject: [PATCH 13/14] debug git config --- .github/workflows/example-get-started-deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/example-get-started-deploy.yaml b/.github/workflows/example-get-started-deploy.yaml index 76c4da4d..7cc131c4 100644 --- a/.github/workflows/example-get-started-deploy.yaml +++ b/.github/workflows/example-get-started-deploy.yaml @@ -38,7 +38,7 @@ jobs: run: | # add remote cd example-get-started/build/example-get-started - git remote add origin https://${{ secrets.GITHUB_TOKEN }}@github.com/iterative/example-get-started.git + git remote add origin https://${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/iterative/example-get-started.git # close open PRs gh pr close try-large-dataset gh pr close tune-hyperparams From 2c98e4128525a7046a6f5ab1fae8884d8fc3605a Mon Sep 17 00:00:00 2001 From: dberenbaum Date: Mon, 25 Sep 2023 15:15:09 -0400 Subject: [PATCH 14/14] try dropping git config --- .github/workflows/example-get-started-deploy.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/example-get-started-deploy.yaml b/.github/workflows/example-get-started-deploy.yaml index 7cc131c4..134c5e42 100644 --- a/.github/workflows/example-get-started-deploy.yaml +++ b/.github/workflows/example-get-started-deploy.yaml @@ -27,8 +27,6 @@ jobs: - uses: iterative/setup-dvc@v1 - name: Generate repo run: | - git config --global user.name dberenbaum - git config --global user.email dave@iterative.ai pip install virtualenv cd example-get-started ./generate.sh true