From 9b5829db4fcb4660f387132791f0c92e440be19f Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Sun, 7 Jun 2020 12:31:26 -0700 Subject: [PATCH] Add github action workflow (#30) * add workflow * fix repo * change image * run docker iamge * fix yaml * login then test * login then test * pull private image * use dockerhub * init * fix workflow rebuild readme * checkout code * add all tests * refactor * set default * annotate workflow * pass secrets * annotate workflow * Fix readme * parameterize test image * refactor into multiple jobs * refactor and restore linting * fix templates * Update .github/workflows/slash-command-dispatch.yml Co-authored-by: Andriy Knysh * Update .github/workflows/slash-command-dispatch.yml Co-authored-by: Andriy Knysh * Update .github/workflows/test.yml Co-authored-by: Andriy Knysh * Update .github/workflows/test.yml Co-authored-by: Andriy Knysh * Update .github/workflows/test.yml Co-authored-by: Andriy Knysh Co-authored-by: Andriy Knysh --- .github/CODEOWNERS | 4 + .github/ISSUE_TEMPLATE/bug_report.md | 37 ++++++++++ .github/ISSUE_TEMPLATE/config.yml | 18 +++++ .github/ISSUE_TEMPLATE/feature_request.md | 36 +++++++++ .github/ISSUE_TEMPLATE/question.md | 0 .github/PULL_REQUEST_TEMPLATE.md | 13 ++++ .github/workflows/slash-command-dispatch.yml | 20 +++++ .github/workflows/test.yml | 77 ++++++++++++++++++++ README.md | 2 +- README.yaml | 6 +- codefresh/test.yml | 74 ------------------- 11 files changed, 209 insertions(+), 78 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/question.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/slash-command-dispatch.yml create mode 100644 .github/workflows/test.yml delete mode 100644 codefresh/test.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..41c1baad --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,4 @@ +# Use this file to define individuals or teams that are responsible for code in a repository. +# Read more: + +* @cloudposse/engineering \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..f3df96b5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,37 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: 'bug' +assignees: '' + +--- + +Found a bug? Maybe our [Slack Community](https://slack.cloudposse.com) can help. + +[![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) + +## Describe the Bug +A clear and concise description of what the bug is. + +## Expected Behavior +A clear and concise description of what you expected to happen. + +## Steps to Reproduce +Steps to reproduce the behavior: +1. Go to '...' +2. Run '....' +3. Enter '....' +4. See error + +## Screenshots +If applicable, add screenshots or logs to help explain your problem. + +## Environment (please complete the following information): + +Anything that will help us triage the bug will help. Here are some ideas: + - OS: [e.g. Linux, OSX, WSL, etc] + - Version [e.g. 10.15] + +## Additional Context +Add any other context about the problem here. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..76ae6d67 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,18 @@ +blank_issues_enabled: false + +contact_links: + + - name: Community Slack Team + url: https://cloudposse.com/slack/ + about: |- + Please ask and answer questions here. + + - name: Office Hours + url: https://cloudposse.com/office-hours/ + about: |- + Join us every Wednesday for FREE Office Hours (lunch & learn). + + - name: DevOps Accelerator Program + url: https://cloudposse.com/accelerate/ + about: |- + Own your infrastructure in record time. We build it. You drive it. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..39a8686f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,36 @@ +--- +name: Feature Request +about: Suggest an idea for this project +title: '' +labels: 'feature request' +assignees: '' + +--- + +Have a question? Please checkout our [Slack Community](https://slack.cloudposse.com) or visit our [Slack Archive](https://archive.sweetops.com/). + +[![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) + +## Describe the Feature + +A clear and concise description of what the bug is. + +## Expected Behavior + +A clear and concise description of what you expected to happen. + +## Use Case + +Is your feature request related to a problem/challenge you are trying to solve? Please provide some additional context of why this feature or capability will be valuable. + +## Describe Ideal Solution + +A clear and concise description of what you want to happen. If you don't know, that's okay. + +## Alternatives Considered + +Explain what alternative solutions or features you've considered. + +## Additional Context + +Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 00000000..e69de29b diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..4b8f32df --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,13 @@ +## what +* Describe high-level what changed as a result of these commits (i.e. in plain-english, what do these changes mean?) +* Use bullet points to be concise and to the point. + +## why +* Provide the justifications for the changes (e.g. business case). +* Describe why these changes were made (e.g. why do these commits fix the problem?) +* Use bullet points to be concise and to the point. + +## references +* Link to any supporting github issues or helpful documentation to add some context (e.g. stackoverflow). +* Use `closes #123`, if this PR closes a GitHub issue `#123` + diff --git a/.github/workflows/slash-command-dispatch.yml b/.github/workflows/slash-command-dispatch.yml new file mode 100644 index 00000000..2b30f339 --- /dev/null +++ b/.github/workflows/slash-command-dispatch.yml @@ -0,0 +1,20 @@ +name: Slash Command Dispatch +on: + issue_comment: + types: [created] + +jobs: + slashCommandDispatch: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Slash Command Dispatch + uses: cloudposse/actions/github/slash-command-dispatch@0.15.0 + with: + token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} + reaction-token: ${{ secrets.GITHUB_TOKEN }} + repository: cloudposse/actions + commands: rebuild-readme, terraform-fmt + permission: none + issue-type: pull-request diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..103b750f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,77 @@ +name: test +on: + # Open a PR to update README for all PRs (as necessary) + pull_request: + types: [opened, synchronize, reopened] + +jobs: + readme: + runs-on: ubuntu-latest + container: cloudposse/testing.cloudposse.co:latest + env: + PATH: "/usr/local/terraform/0.12/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + MAKE_INCLUDES: Makefile + steps: + + # Checkout the code from GitHub + - name: "Checkout code" + uses: actions/checkout@v2 + + # Initialize the build-harness with make target helpers + - name: "Initialize build-harness" + env: + BUILD_HARNESS_BRANCH: master + run: make init + + # Run the bats tests from the test-harness against the module + - name: "Test that README.md was generated from README.yaml" + run: make readme/lint + + bats: + runs-on: ubuntu-latest + container: cloudposse/testing.cloudposse.co:latest + env: + PATH: "/usr/local/terraform/0.12/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + MAKE_INCLUDES: Makefile + steps: + + # Checkout the code from GitHub + - name: "Checkout code" + uses: actions/checkout@v2 + + # Initialize the test-harness which has a library of bats tests + - name: "Initialize test-harness" + env: + TEST_HARNESS_BRANCH: master + run: make -C test/ clean init + + # Run the bats tests from the test-harness against the module + - name: "Test module with bats" + run: make -C test/ module + + # Run the bats tests from the test-harness against the example + - name: "Test `examples/complete` with bats" + run: make -C test/ examples/complete + + terratest: + runs-on: ubuntu-latest + container: cloudposse/testing.cloudposse.co:latest + env: + PATH: "/usr/local/terraform/0.12/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + MAKE_INCLUDES: Makefile + steps: + + # Checkout the code from GitHub + - name: "Checkout code" + uses: actions/checkout@v2 + + # Initialize the terratest go project + - name: "Initialize terratest go project" + run: make -C test/src clean init + + # Run the terratest integration tests + - name: "Test `examples/complete` with terratest" + run: make -C test/src + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }} diff --git a/README.md b/README.md index b4725569..b98de277 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ [![Cloud Posse][logo]](https://cpco.io/homepage) -# terraform-aws-s3-bucket [![Codefresh Build Status](https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-aws-s3-bucket?type=cf-1)](https://g.codefresh.io/public/accounts/cloudposse/pipelines/5d13993639efa9451b1a2aa4) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-s3-bucket.svg)](https://github.com/cloudposse/terraform-aws-s3-bucket/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) +# terraform-aws-s3-bucket [![GitHub Action Tests](https://github.com/cloudposse/terraform-aws-s3-bucket/workflows/test/badge.svg?branch=master)](https://github.com/cloudposse/terraform-aws-s3-bucket/actions) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-s3-bucket.svg)](https://github.com/cloudposse/terraform-aws-s3-bucket/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) This module creates an S3 bucket with support of versioning, encryption, ACL and bucket object policy. diff --git a/README.yaml b/README.yaml index 4965a086..4684dd63 100644 --- a/README.yaml +++ b/README.yaml @@ -33,9 +33,9 @@ github_repo: cloudposse/terraform-aws-s3-bucket # Badges to display badges: - - name: "Codefresh Build Status" - image: "https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-aws-s3-bucket?type=cf-1" - url: "https://g.codefresh.io/public/accounts/cloudposse/pipelines/5d13993639efa9451b1a2aa4" + - name: "GitHub Action Tests" + image: "https://github.com/cloudposse/terraform-aws-s3-bucket/workflows/test/badge.svg?branch=master" + url: "https://github.com/cloudposse/terraform-aws-s3-bucket/actions" - name: "Latest Release" image: "https://img.shields.io/github/release/cloudposse/terraform-aws-s3-bucket.svg" url: "https://github.com/cloudposse/terraform-aws-s3-bucket/releases/latest" diff --git a/codefresh/test.yml b/codefresh/test.yml deleted file mode 100644 index ddd07f97..00000000 --- a/codefresh/test.yml +++ /dev/null @@ -1,74 +0,0 @@ -version: '1.0' - -stages: - - Prepare - - Test - -steps: - wait: - title: Wait - stage: Prepare - image: codefresh/cli:latest - commands: - - codefresh get builds --pipeline=${{CF_REPO_NAME}} --status running --limit 1000 -o json | jq --arg id ${{CF_BUILD_ID}} -ser 'flatten|.[-1].id==$id' - retry: - maxAttempts: 10 - delay: 20 - exponentialFactor: 1.1 - - main_clone: - title: "Clone repository" - type: git-clone - stage: Prepare - description: "Initialize" - repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}} - git: CF-default - revision: ${{CF_REVISION}} - - clean_init: - title: Prepare build-harness and test-harness - image: ${{TEST_IMAGE}} - stage: Prepare - commands: - - cf_export PATH="/usr/local/terraform/0.12/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" - - make init - - git -C build-harness checkout master - - make -C test/ clean init TEST_HARNESS_BRANCH=master - - make -C test/src clean init - - find . -type d -name '.terraform' | xargs rm -rf - - find . -type f -name 'terraform.tfstate*' -exec rm -f {} \; - - test: - type: "parallel" - title: "Run tests" - description: "Run all tests in parallel" - stage: Test - steps: - test_readme_lint: - title: "Test README.md updated" - stage: "Test" - image: ${{TEST_IMAGE}} - description: Test "readme/lint" - commands: - - make readme/lint - - test_module: - title: Test module with bats - image: ${{TEST_IMAGE}} - stage: Test - commands: - - make -C test/ module - - test_examples_complete: - title: Test "examples/complete" with bats - image: ${{TEST_IMAGE}} - stage: Test - commands: - - make -C test/ examples/complete - - test_examples_complete_terratest: - title: Test "examples/complete" with terratest - image: ${{TEST_IMAGE}} - stage: Test - commands: - - make -C test/src