From c150c84489411df61c0bf70df86737e1ac81dbc8 Mon Sep 17 00:00:00 2001 From: lamont Date: Fri, 5 Mar 2021 23:17:06 -0800 Subject: [PATCH 01/11] matrix expansion of cookbooks in single repo --- .github/workflows/pull_request_chef.yml | 48 +++++++++++++++++-- .../workflows/push_to_environment_chef.yml | 2 +- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pull_request_chef.yml b/.github/workflows/pull_request_chef.yml index ec562c7..0ad3d7f 100644 --- a/.github/workflows/pull_request_chef.yml +++ b/.github/workflows/pull_request_chef.yml @@ -4,16 +4,56 @@ on: paths: - 'chef-repo/**' jobs: - preview: - name: Preview Chef-${{ github.base_ref }} + enumerate_cookbooks: + name: Enumerate Cookbooks runs-on: ubuntu-latest - container: docker://chef/chefworkstation steps: - - uses: kvrhdn/gha-buildevents@main + - uses: kvrhdn/gha-buildevents@main with: apikey: ${{ secrets.BUILDEVENTS_APIKEY }} dataset: gha-buildevents_integration job-status: ${{ job.status }} + - uses: actions/checkout@v2 + - id: cookbook_list + run: echo "::set-output name=matrix::$(find chef-repo/cookbooks -type d -depth 1 | awk -F/ '{print $3}')" + outputs: + matrix: ${{ steps.cookbook_list.outputs.matrix }} + test_cookbooks: + name: Test Cookbooks + needs: enumerate_cookbooks + runs-on: ubuntu-latest + container: docker://chef/chefworkstation + strategy: + matrix: + cookbook: ${{ fromJson(needs.enumerate_cookbooks.outputs.matrix) }} + steps: + - uses: actions/checkout@v2 + - name: 'Chef Lint' + uses: FastRobot/chef-cookbook-action@main + with: + chef_actions_task: 'lint' + chef_actions_working_dir: chef-repo/cookbooks/${{ matrix.cookbook }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: 'Unit Tests' + uses: FastRobot/chef-cookbook-action@main + with: + chef_actions_task: 'spec' + chef_actions_working_dir: chef-repo/cookbooks/${{ matrix.cookbook }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: 'Kitchen Tests' + uses: FastRobot/chef-cookbook-action@main + with: + chef_actions_task: 'kitchen' + chef_actions_working_dir: chef-repo/cookbooks/${{ matrix.cookbook }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + preview: + name: Preview Chef-${{ github.base_ref }} + runs-on: ubuntu-latest + container: docker://chef/chefworkstation + steps: - uses: actions/checkout@v2 with: fetch-depth: 1 diff --git a/.github/workflows/push_to_environment_chef.yml b/.github/workflows/push_to_environment_chef.yml index 8eda6f8..e1591fb 100644 --- a/.github/workflows/push_to_environment_chef.yml +++ b/.github/workflows/push_to_environment_chef.yml @@ -39,4 +39,4 @@ jobs: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_REGION: us-west-2 - PULUMI_BACKEND_URL: s3://fr-personal-account-config/cdktf-test/ + S3_BACKEND_URL: s3://fr-personal-account-config/cdktf-test/ From 2481d42b761aa06a7c2e47e8f2558493b30dc30c Mon Sep 17 00:00:00 2001 From: lamont Date: Fri, 5 Mar 2021 23:18:43 -0800 Subject: [PATCH 02/11] oh yaml, why. --- .github/workflows/pull_request_chef.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull_request_chef.yml b/.github/workflows/pull_request_chef.yml index 0ad3d7f..561afb5 100644 --- a/.github/workflows/pull_request_chef.yml +++ b/.github/workflows/pull_request_chef.yml @@ -9,10 +9,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: kvrhdn/gha-buildevents@main - with: - apikey: ${{ secrets.BUILDEVENTS_APIKEY }} - dataset: gha-buildevents_integration - job-status: ${{ job.status }} + with: + apikey: ${{ secrets.BUILDEVENTS_APIKEY }} + dataset: gha-buildevents_integration + job-status: ${{ job.status }} - uses: actions/checkout@v2 - id: cookbook_list run: echo "::set-output name=matrix::$(find chef-repo/cookbooks -type d -depth 1 | awk -F/ '{print $3}')" From 9cff74617f58df803aac150804ca5fc480e83a66 Mon Sep 17 00:00:00 2001 From: lamont Date: Fri, 5 Mar 2021 23:20:28 -0800 Subject: [PATCH 03/11] more indentation. --- .github/workflows/pull_request_chef.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull_request_chef.yml b/.github/workflows/pull_request_chef.yml index 561afb5..e691b01 100644 --- a/.github/workflows/pull_request_chef.yml +++ b/.github/workflows/pull_request_chef.yml @@ -13,9 +13,9 @@ jobs: apikey: ${{ secrets.BUILDEVENTS_APIKEY }} dataset: gha-buildevents_integration job-status: ${{ job.status }} - - uses: actions/checkout@v2 - - id: cookbook_list - run: echo "::set-output name=matrix::$(find chef-repo/cookbooks -type d -depth 1 | awk -F/ '{print $3}')" + - uses: actions/checkout@v2 + - id: cookbook_list + run: echo "::set-output name=matrix::$(find chef-repo/cookbooks -type d -depth 1 | awk -F/ '{print $3}')" outputs: matrix: ${{ steps.cookbook_list.outputs.matrix }} test_cookbooks: From 8b0dffcd006997a9a00e95e6bc786bd6c09ca3c1 Mon Sep 17 00:00:00 2001 From: lamont Date: Fri, 5 Mar 2021 23:22:58 -0800 Subject: [PATCH 04/11] trigger a run by removing the path constraint --- .github/workflows/pull_request_chef.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_request_chef.yml b/.github/workflows/pull_request_chef.yml index e691b01..186a037 100644 --- a/.github/workflows/pull_request_chef.yml +++ b/.github/workflows/pull_request_chef.yml @@ -1,8 +1,8 @@ name: Chef PR preview on: pull_request: - paths: - - 'chef-repo/**' + #paths: + # - 'chef-repo/**' jobs: enumerate_cookbooks: name: Enumerate Cookbooks From bfc031c89c20650e610a4c883bfb7546f14cc590 Mon Sep 17 00:00:00 2001 From: lamont Date: Fri, 5 Mar 2021 23:30:10 -0800 Subject: [PATCH 05/11] osx vs gnu find --- .github/workflows/pull_request_chef.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request_chef.yml b/.github/workflows/pull_request_chef.yml index 186a037..3c1ed2c 100644 --- a/.github/workflows/pull_request_chef.yml +++ b/.github/workflows/pull_request_chef.yml @@ -15,7 +15,7 @@ jobs: job-status: ${{ job.status }} - uses: actions/checkout@v2 - id: cookbook_list - run: echo "::set-output name=matrix::$(find chef-repo/cookbooks -type d -depth 1 | awk -F/ '{print $3}')" + run: echo "::set-output name=matrix::$(find chef-repo/cookbooks -type d -maxdepth 1 | awk -F/ '{print $3}')" outputs: matrix: ${{ steps.cookbook_list.outputs.matrix }} test_cookbooks: From a88f8276702d9c0ee4e4f03eead87e0d6778515f Mon Sep 17 00:00:00 2001 From: lamont Date: Fri, 5 Mar 2021 23:36:53 -0800 Subject: [PATCH 06/11] got rid of extra step --- .github/workflows/pull_request_chef.yml | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/.github/workflows/pull_request_chef.yml b/.github/workflows/pull_request_chef.yml index 3c1ed2c..385cd91 100644 --- a/.github/workflows/pull_request_chef.yml +++ b/.github/workflows/pull_request_chef.yml @@ -49,23 +49,4 @@ jobs: chef_actions_working_dir: chef-repo/cookbooks/${{ matrix.cookbook }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - preview: - name: Preview Chef-${{ github.base_ref }} - runs-on: ubuntu-latest - container: docker://chef/chefworkstation - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 1 - - name: chef workstation-${{ github.base_ref }} - working-directory: ./chef-repo - run: | - ls -al - chef -v - pwd - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: us-west-2 - S3_BACKEND_URL: s3://fr-personal-account-config/cdktf-test/ - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + From dbeb77a043001598e4a66209ad3314ded25908eb Mon Sep 17 00:00:00 2001 From: lamont Date: Sat, 6 Mar 2021 13:30:43 -0800 Subject: [PATCH 07/11] hard-code cookbook steps to test the next phase --- .github/workflows/pull_request_chef.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull_request_chef.yml b/.github/workflows/pull_request_chef.yml index 385cd91..0064628 100644 --- a/.github/workflows/pull_request_chef.yml +++ b/.github/workflows/pull_request_chef.yml @@ -15,7 +15,8 @@ jobs: job-status: ${{ job.status }} - uses: actions/checkout@v2 - id: cookbook_list - run: echo "::set-output name=matrix::$(find chef-repo/cookbooks -type d -maxdepth 1 | awk -F/ '{print $3}')" + # later replace this with a helper script from inside a container. + run: echo '::set-output name=matrix::$(["ourBase", "ourMonitoring"])' outputs: matrix: ${{ steps.cookbook_list.outputs.matrix }} test_cookbooks: From 565ec7677795eaac5292e952bec598ad0a214f1f Mon Sep 17 00:00:00 2001 From: lamont Date: Sat, 6 Mar 2021 13:32:39 -0800 Subject: [PATCH 08/11] always quoting --- .github/workflows/pull_request_chef.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request_chef.yml b/.github/workflows/pull_request_chef.yml index 0064628..c770b1b 100644 --- a/.github/workflows/pull_request_chef.yml +++ b/.github/workflows/pull_request_chef.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v2 - id: cookbook_list # later replace this with a helper script from inside a container. - run: echo '::set-output name=matrix::$(["ourBase", "ourMonitoring"])' + run: echo ::set-output name=matrix::$(["ourBase", "ourMonitoring"]) outputs: matrix: ${{ steps.cookbook_list.outputs.matrix }} test_cookbooks: From 189d6200864e90040d8407449ff1f0033515fab3 Mon Sep 17 00:00:00 2001 From: lamont Date: Sat, 6 Mar 2021 13:34:51 -0800 Subject: [PATCH 09/11] quotes in quotes in quotes --- .github/workflows/pull_request_chef.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request_chef.yml b/.github/workflows/pull_request_chef.yml index c770b1b..0539efb 100644 --- a/.github/workflows/pull_request_chef.yml +++ b/.github/workflows/pull_request_chef.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v2 - id: cookbook_list # later replace this with a helper script from inside a container. - run: echo ::set-output name=matrix::$(["ourBase", "ourMonitoring"]) + run: echo "::set-output name=matrix::$([\"ourBase\", \"ourMonitoring\"])" outputs: matrix: ${{ steps.cookbook_list.outputs.matrix }} test_cookbooks: From 57db60de2f7d63eea2749b97f74c381452b7c35b Mon Sep 17 00:00:00 2001 From: lamont Date: Sat, 6 Mar 2021 13:38:00 -0800 Subject: [PATCH 10/11] forgot its a string, not a shell out --- .github/workflows/pull_request_chef.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request_chef.yml b/.github/workflows/pull_request_chef.yml index 0539efb..6ef91fe 100644 --- a/.github/workflows/pull_request_chef.yml +++ b/.github/workflows/pull_request_chef.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v2 - id: cookbook_list # later replace this with a helper script from inside a container. - run: echo "::set-output name=matrix::$([\"ourBase\", \"ourMonitoring\"])" + run: echo "::set-output name=matrix::[\"ourBase\", \"ourMonitoring\"]" outputs: matrix: ${{ steps.cookbook_list.outputs.matrix }} test_cookbooks: From 4250bfeaca7482132fdc5ddbe095be59e3d44bf7 Mon Sep 17 00:00:00 2001 From: lamont Date: Tue, 20 Apr 2021 15:10:21 -0700 Subject: [PATCH 11/11] run the chef workflow on chef-repo/ and chef workflow file changes. --- .github/workflows/pull_request_chef.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_request_chef.yml b/.github/workflows/pull_request_chef.yml index 6ef91fe..01b5018 100644 --- a/.github/workflows/pull_request_chef.yml +++ b/.github/workflows/pull_request_chef.yml @@ -1,8 +1,9 @@ name: Chef PR preview on: pull_request: - #paths: - # - 'chef-repo/**' + paths: + - 'chef-repo/**' + - '.github/workflows/*_chef.yml' jobs: enumerate_cookbooks: name: Enumerate Cookbooks