├── .github ├── settings.yml └── workflows │ ├── branch.yml │ ├── release.yml │ ├── test-negative.yml │ └── test-positive.yml ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── README.yaml ├── action.yml ├── docs └── github-action.md ├── renovate.json └── tests └── fixtures └── test ├── docker-compose.yml ├── test-failure.sh └── test-success.sh /.github/settings.yml: -------------------------------------------------------------------------------- 1 | # Upstream changes from _extends are only recognized when modifications are made to this file in the default branch. 2 | _extends: .github 3 | repository: 4 | name: github-action-docker-compose-test-run 5 | description: Up docker compose and run tests in specific container 6 | homepage: https://cloudposse.com/accelerate 7 | topics: "" 8 | 9 | -------------------------------------------------------------------------------- /.github/workflows/branch.yml: -------------------------------------------------------------------------------- 1 | name: Branch 2 | on: 3 | pull_request: 4 | branches: 5 | - main 6 | - release/** 7 | types: [opened, synchronize, reopened] 8 | push: 9 | branches: 10 | - main 11 | - release/v* 12 | paths-ignore: 13 | - '.github/**' 14 | - 'docs/**' 15 | - 'examples/**' 16 | - 'test/**' 17 | - 'README.md' 18 | 19 | permissions: 20 | contents: write 21 | actions: write 22 | 23 | jobs: 24 | github-action: 25 | uses: cloudposse/.github/.github/workflows/shared-github-action.yml@main 26 | secrets: inherit 27 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | on: 3 | release: 4 | types: [published] 5 | 6 | permissions: 7 | id-token: write 8 | contents: write 9 | pull-requests: write 10 | 11 | jobs: 12 | github-action: 13 | uses: cloudposse/.github/.github/workflows/shared-release-branches.yml@main 14 | secrets: inherit 15 | -------------------------------------------------------------------------------- /.github/workflows/test-negative.yml: -------------------------------------------------------------------------------- 1 | name: Tests failed 2 | on: 3 | # # Uncomment when test added first time to register workflow and comment it back after workflow would be registered 4 | # # 5 | # # Added pull_request to register workflow from the PR. 6 | # # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo 7 | # pull_request: {} 8 | workflow_dispatch: {} 9 | 10 | jobs: 11 | setup: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Setup 15 | run: echo "Do setup" 16 | 17 | test: 18 | runs-on: ubuntu-latest 19 | needs: [setup] 20 | continue-on-error: true 21 | steps: 22 | - name: Checkout 23 | uses: actions/checkout@v4 24 | 25 | - uses: ./ 26 | id: current 27 | with: 28 | workdir: ./tests/fixtures/ 29 | file: test/docker-compose.yml 30 | service: app 31 | command: test/test-failure.sh 32 | registry: registry.hub.docker.com 33 | login: ${{ secrets.DOCKERHUB_USERNAME }} 34 | password: ${{ secrets.DOCKERHUB_PASSWORD }} 35 | 36 | outputs: 37 | result: ${{ steps.current.conclusion }} 38 | 39 | assert: 40 | runs-on: ubuntu-latest 41 | needs: [test] 42 | steps: 43 | - uses: nick-fields/assert-action@v1 44 | with: 45 | expected: 'failure' 46 | actual: ${{ needs.test.outputs.result }} 47 | 48 | teardown: 49 | runs-on: ubuntu-latest 50 | needs: [assert] 51 | if: ${{ always() }} 52 | steps: 53 | - name: Tear down 54 | run: echo "Do Tear down" 55 | -------------------------------------------------------------------------------- /.github/workflows/test-positive.yml: -------------------------------------------------------------------------------- 1 | name: Tests passed 2 | on: 3 | # # Uncomment when test added first time to register workflow and comment it back after workflow would be registered 4 | # # 5 | # # Added pull_request to register workflow from the PR. 6 | # # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo 7 | # pull_request: {} 8 | workflow_dispatch: {} 9 | 10 | jobs: 11 | setup: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Setup 15 | run: echo "Do setup" 16 | 17 | test: 18 | runs-on: ubuntu-latest 19 | needs: [setup] 20 | continue-on-error: true 21 | steps: 22 | - name: Checkout 23 | uses: actions/checkout@v4 24 | 25 | - uses: ./ 26 | id: current 27 | with: 28 | workdir: ./tests/fixtures/ 29 | file: test/docker-compose.yml 30 | service: app 31 | command: test/test-success.sh 32 | registry: registry.hub.docker.com 33 | login: ${{ secrets.DOCKERHUB_USERNAME }} 34 | password: ${{ secrets.DOCKERHUB_PASSWORD }} 35 | 36 | outputs: 37 | result: ${{ steps.current.conclusion }} 38 | 39 | assert: 40 | runs-on: ubuntu-latest 41 | needs: [test] 42 | steps: 43 | - uses: nick-fields/assert-action@v1 44 | with: 45 | expected: 'success' 46 | actual: ${{ needs.test.outputs.result }} 47 | 48 | teardown: 49 | runs-on: ubuntu-latest 50 | needs: [assert] 51 | if: ${{ always() }} 52 | steps: 53 | - name: Tear down 54 | run: echo "Do Tear down" 55 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .build-harness 2 | build-harness -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SHELL := /bin/bash 2 | 3 | # List of targets the `readme` target should call before generating the readme 4 | export README_DEPS ?= docs/github-action.md 5 | 6 | -include $(shell curl -sSL -o .build-harness "https://cloudposse.tools/build-harness"; echo .build-harness) 7 | 8 | ## Lint terraform code 9 | lint: 10 | $(SELF) terraform/install terraform/get-modules terraform/get-plugins terraform/lint terraform/validate -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # github-action-docker-compose-test-run 4 | 5 | [![Latest Release](https://img.shields.io/github/release/cloudposse/github-action-docker-compose-test-run.svg)](https://github.com/cloudposse/github-action-docker-compose-test-run/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) 6 | 7 | 8 | [![README Header][readme_header_img]][readme_header_link] 9 | 10 | [![Cloud Posse][logo]](https://cpco.io/homepage) 11 | 12 | 32 | 33 | Up docker compose and run tests in specific container 34 | 35 | --- 36 | 37 | This project is part of our comprehensive ["SweetOps"](https://cpco.io/sweetops) approach towards DevOps. 38 | [][share_email] 39 | [][share_googleplus] 40 | [][share_facebook] 41 | [][share_reddit] 42 | [][share_linkedin] 43 | [][share_twitter] 44 | 45 | 46 | 47 | 48 | It's 100% Open Source and licensed under the [APACHE2](LICENSE). 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | ## Introduction 62 | 63 | Run tests in enviroment defined with Docker Compose 64 | 65 | 66 | 67 | 68 | 69 | ## Usage 70 | 71 | 72 | 73 | ```yaml 74 | name: Push into Main 75 | on: 76 | push: 77 | branches: [ master ] 78 | 79 | jobs: 80 | test: 81 | runs-on: ubuntu-latest 82 | steps: 83 | - name: Checkout 84 | uses: actions/checkout@v3 85 | 86 | - name: Tests 87 | uses: cloudposse/github-action-docker-compose-test-run@main 88 | with: 89 | file: test/docker-compose.yml 90 | service: app 91 | command: test/unit-tests.sh 92 | ``` 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | ## Inputs 102 | 103 | | Name | Description | Default | Required | 104 | |------|-------------|---------|----------| 105 | | command | Command to run tests | N/A | true | 106 | | docker-compose-version | Docker compose version | 1.29.2 | false | 107 | | entrypoint | Entrypoint | /bin/sh | false | 108 | | file | Docker compose file | N/A | true | 109 | | login | Docker login | | false | 110 | | password | Docker password | | false | 111 | | registry | Docker registry | N/A | true | 112 | | service | Service run tests inside | N/A | true | 113 | | workdir | Working directory | ./ | false | 114 | 115 | 116 | ## Outputs 117 | 118 | | Name | Description | 119 | |------|-------------| 120 | 121 | 122 | 123 | 124 | ## Share the Love 125 | 126 | Like this project? Please give it a ★ on [our GitHub](https://github.com/cloudposse/github-action-docker-compose-test-run)! (it helps us **a lot**) 127 | 128 | Are you using this project or any of our other projects? Consider [leaving a testimonial][testimonial]. =) 129 | 130 | 131 | 132 | ## Related Projects 133 | 134 | Check out these related projects. 135 | 136 | 137 | 138 | ## References 139 | 140 | For additional context, refer to some of these links. 141 | 142 | - [github-actions-workflows](https://github.com/cloudposse/github-actions-workflows) - Reusable workflows for different types of projects 143 | - [example-github-action-release-workflow](https://github.com/cloudposse/example-github-action-release-workflow) - Example application with complicated release workflow 144 | 145 | 146 | ## Help 147 | 148 | **Got a question?** We got answers. 149 | 150 | File a GitHub [issue](https://github.com/cloudposse/github-action-docker-compose-test-run/issues), send us an [email][email] or join our [Slack Community][slack]. 151 | 152 | [![README Commercial Support][readme_commercial_support_img]][readme_commercial_support_link] 153 | 154 | ## DevOps Accelerator for Startups 155 | 156 | 157 | We are a [**DevOps Accelerator**][commercial_support]. We'll help you build your cloud infrastructure from the ground up so you can own it. Then we'll show you how to operate it and stick around for as long as you need us. 158 | 159 | [![Learn More](https://img.shields.io/badge/learn%20more-success.svg?style=for-the-badge)][commercial_support] 160 | 161 | Work directly with our team of DevOps experts via email, slack, and video conferencing. 162 | 163 | We deliver 10x the value for a fraction of the cost of a full-time engineer. Our track record is not even funny. If you want things done right and you need it done FAST, then we're your best bet. 164 | 165 | - **Reference Architecture.** You'll get everything you need from the ground up built using 100% infrastructure as code. 166 | - **Release Engineering.** You'll have end-to-end CI/CD with unlimited staging environments. 167 | - **Site Reliability Engineering.** You'll have total visibility into your apps and microservices. 168 | - **Security Baseline.** You'll have built-in governance with accountability and audit logs for all changes. 169 | - **GitOps.** You'll be able to operate your infrastructure via Pull Requests. 170 | - **Training.** You'll receive hands-on training so your team can operate what we build. 171 | - **Questions.** You'll have a direct line of communication between our teams via a Shared Slack channel. 172 | - **Troubleshooting.** You'll get help to triage when things aren't working. 173 | - **Code Reviews.** You'll receive constructive feedback on Pull Requests. 174 | - **Bug Fixes.** We'll rapidly work with you to fix any bugs in our projects. 175 | 176 | ## Slack Community 177 | 178 | Join our [Open Source Community][slack] on Slack. It's **FREE** for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally *sweet* infrastructure. 179 | 180 | ## Discourse Forums 181 | 182 | Participate in our [Discourse Forums][discourse]. Here you'll find answers to commonly asked questions. Most questions will be related to the enormous number of projects we support on our GitHub. Come here to collaborate on answers, find solutions, and get ideas about the products and services we value. It only takes a minute to get started! Just sign in with SSO using your GitHub account. 183 | 184 | ## Newsletter 185 | 186 | Sign up for [our newsletter][newsletter] that covers everything on our technology radar. Receive updates on what we're up to on GitHub as well as awesome new projects we discover. 187 | 188 | ## Office Hours 189 | 190 | [Join us every Wednesday via Zoom][office_hours] for our weekly "Lunch & Learn" sessions. It's **FREE** for everyone! 191 | 192 | [![zoom](https://img.cloudposse.com/fit-in/200x200/https://cloudposse.com/wp-content/uploads/2019/08/Powered-by-Zoom.png")][office_hours] 193 | 194 | ## Contributing 195 | 196 | ### Bug Reports & Feature Requests 197 | 198 | Please use the [issue tracker](https://github.com/cloudposse/github-action-docker-compose-test-run/issues) to report any bugs or file feature requests. 199 | 200 | ### Developing 201 | 202 | If you are interested in being a contributor and want to get involved in developing this project or [help out](https://cpco.io/help-out) with our other projects, we would love to hear from you! Shoot us an [email][email]. 203 | 204 | In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. 205 | 206 | 1. **Fork** the repo on GitHub 207 | 2. **Clone** the project to your own machine 208 | 3. **Commit** changes to your own branch 209 | 4. **Push** your work back up to your fork 210 | 5. Submit a **Pull Request** so that we can review your changes 211 | 212 | **NOTE:** Be sure to merge the latest changes from "upstream" before making a pull request! 213 | 214 | 215 | ## Copyright 216 | 217 | Copyright © 2017-2023 [Cloud Posse, LLC](https://cpco.io/copyright) 218 | 219 | 220 | 221 | ## License 222 | 223 | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 224 | 225 | See [LICENSE](LICENSE) for full details. 226 | 227 | ```text 228 | Licensed to the Apache Software Foundation (ASF) under one 229 | or more contributor license agreements. See the NOTICE file 230 | distributed with this work for additional information 231 | regarding copyright ownership. The ASF licenses this file 232 | to you under the Apache License, Version 2.0 (the 233 | "License"); you may not use this file except in compliance 234 | with the License. You may obtain a copy of the License at 235 | 236 | https://www.apache.org/licenses/LICENSE-2.0 237 | 238 | Unless required by applicable law or agreed to in writing, 239 | software distributed under the License is distributed on an 240 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 241 | KIND, either express or implied. See the License for the 242 | specific language governing permissions and limitations 243 | under the License. 244 | ``` 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | ## Trademarks 255 | 256 | All other trademarks referenced herein are the property of their respective owners. 257 | 258 | ## About 259 | 260 | This project is maintained and funded by [Cloud Posse, LLC][website]. Like it? Please let us know by [leaving a testimonial][testimonial]! 261 | 262 | [![Cloud Posse][logo]][website] 263 | 264 | We're a [DevOps Professional Services][hire] company based in Los Angeles, CA. We ❤️ [Open Source Software][we_love_open_source]. 265 | 266 | We offer [paid support][commercial_support] on all of our projects. 267 | 268 | Check out [our other projects][github], [follow us on twitter][twitter], [apply for a job][jobs], or [hire us][hire] to help with your cloud strategy and implementation. 269 | 270 | 271 | 272 | ### Contributors 273 | 274 | 275 | | [![Igor Rodionov][goruha_avatar]][goruha_homepage]
[Igor Rodionov][goruha_homepage] | 276 | |---| 277 | 278 | 279 | [goruha_homepage]: https://github.com/goruha 280 | [goruha_avatar]: https://img.cloudposse.com/150x150/https://github.com/goruha.png 281 | 282 | [![README Footer][readme_footer_img]][readme_footer_link] 283 | [![Beacon][beacon]][website] 284 | 285 | [logo]: https://cloudposse.com/logo-300x69.svg 286 | [docs]: https://cpco.io/docs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-compose-test-run&utm_content=docs 287 | [website]: https://cpco.io/homepage?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-compose-test-run&utm_content=website 288 | [github]: https://cpco.io/github?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-compose-test-run&utm_content=github 289 | [jobs]: https://cpco.io/jobs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-compose-test-run&utm_content=jobs 290 | [hire]: https://cpco.io/hire?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-compose-test-run&utm_content=hire 291 | [slack]: https://cpco.io/slack?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-compose-test-run&utm_content=slack 292 | [linkedin]: https://cpco.io/linkedin?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-compose-test-run&utm_content=linkedin 293 | [twitter]: https://cpco.io/twitter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-compose-test-run&utm_content=twitter 294 | [testimonial]: https://cpco.io/leave-testimonial?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-compose-test-run&utm_content=testimonial 295 | [office_hours]: https://cloudposse.com/office-hours?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-compose-test-run&utm_content=office_hours 296 | [newsletter]: https://cpco.io/newsletter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-compose-test-run&utm_content=newsletter 297 | [discourse]: https://ask.sweetops.com/?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-compose-test-run&utm_content=discourse 298 | [email]: https://cpco.io/email?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-compose-test-run&utm_content=email 299 | [commercial_support]: https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-compose-test-run&utm_content=commercial_support 300 | [we_love_open_source]: https://cpco.io/we-love-open-source?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-compose-test-run&utm_content=we_love_open_source 301 | [terraform_modules]: https://cpco.io/terraform-modules?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-compose-test-run&utm_content=terraform_modules 302 | [readme_header_img]: https://cloudposse.com/readme/header/img 303 | [readme_header_link]: https://cloudposse.com/readme/header/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-compose-test-run&utm_content=readme_header_link 304 | [readme_footer_img]: https://cloudposse.com/readme/footer/img 305 | [readme_footer_link]: https://cloudposse.com/readme/footer/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-compose-test-run&utm_content=readme_footer_link 306 | [readme_commercial_support_img]: https://cloudposse.com/readme/commercial-support/img 307 | [readme_commercial_support_link]: https://cloudposse.com/readme/commercial-support/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-compose-test-run&utm_content=readme_commercial_support_link 308 | [share_twitter]: https://twitter.com/intent/tweet/?text=github-action-docker-compose-test-run&url=https://github.com/cloudposse/github-action-docker-compose-test-run 309 | [share_linkedin]: https://www.linkedin.com/shareArticle?mini=true&title=github-action-docker-compose-test-run&url=https://github.com/cloudposse/github-action-docker-compose-test-run 310 | [share_reddit]: https://reddit.com/submit/?url=https://github.com/cloudposse/github-action-docker-compose-test-run 311 | [share_facebook]: https://facebook.com/sharer/sharer.php?u=https://github.com/cloudposse/github-action-docker-compose-test-run 312 | [share_googleplus]: https://plus.google.com/share?url=https://github.com/cloudposse/github-action-docker-compose-test-run 313 | [share_email]: mailto:?subject=github-action-docker-compose-test-run&body=https://github.com/cloudposse/github-action-docker-compose-test-run 314 | [beacon]: https://ga-beacon.cloudposse.com/UA-76589703-4/cloudposse/github-action-docker-compose-test-run?pixel&cs=github&cm=readme&an=github-action-docker-compose-test-run 315 | 316 | -------------------------------------------------------------------------------- /README.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # This is the canonical configuration for the `README.md` 4 | # Run `make readme` to rebuild the `README.md` 5 | # 6 | 7 | # Name of this project 8 | name: github-action-docker-compose-test-run 9 | 10 | # Tags of this project 11 | tags: 12 | - github-action 13 | 14 | # Logo for this project 15 | #logo: docs/logo.png 16 | 17 | # License of this project 18 | license: "APACHE2" 19 | 20 | # Canonical GitHub repo 21 | github_repo: cloudposse/github-action-docker-compose-test-run 22 | 23 | # Badges to display 24 | badges: 25 | - name: "Latest Release" 26 | image: "https://img.shields.io/github/release/cloudposse/github-action-docker-compose-test-run.svg" 27 | url: "https://github.com/cloudposse/github-action-docker-compose-test-run/releases/latest" 28 | - name: "Slack Community" 29 | image: "https://slack.cloudposse.com/badge.svg" 30 | url: "https://slack.cloudposse.com" 31 | 32 | related: [] 33 | 34 | # Short description of this project 35 | description: Up docker compose and run tests in specific container 36 | 37 | introduction: |- 38 | Run tests in enviroment defined with Docker Compose 39 | 40 | references: 41 | - name: "github-actions-workflows" 42 | description: "Reusable workflows for different types of projects" 43 | url: "https://github.com/cloudposse/github-actions-workflows" 44 | - name: "example-github-action-release-workflow" 45 | description: "Example application with complicated release workflow" 46 | url: "https://github.com/cloudposse/example-github-action-release-workflow" 47 | 48 | # How to use this project 49 | usage: |- 50 | ```yaml 51 | name: Push into Main 52 | on: 53 | push: 54 | branches: [ master ] 55 | 56 | jobs: 57 | test: 58 | runs-on: ubuntu-latest 59 | steps: 60 | - name: Checkout 61 | uses: actions/checkout@v3 62 | 63 | - name: Tests 64 | uses: cloudposse/github-action-docker-compose-test-run@main 65 | with: 66 | file: test/docker-compose.yml 67 | service: app 68 | command: test/unit-tests.sh 69 | ``` 70 | 71 | include: 72 | - "docs/github-action.md" 73 | 74 | # Contributors to this project 75 | contributors: 76 | - name: "Igor Rodionov" 77 | github: "goruha" -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Docker compose tests run' 2 | description: 'Run tests in docker compose environment' 3 | author: hello@cloudposse.com 4 | branding: 5 | icon: 'grid' 6 | color: 'white' 7 | inputs: 8 | workdir: 9 | description: 'Working directory' 10 | required: false 11 | default: './' 12 | file: 13 | description: 'Docker compose file' 14 | required: true 15 | service: 16 | description: 'Service run tests inside' 17 | required: true 18 | entrypoint: 19 | description: 'Entrypoint' 20 | default: '/bin/sh' 21 | required: false 22 | command: 23 | description: 'Command to run tests' 24 | required: true 25 | docker-compose-version: 26 | description: 'Docker compose version' 27 | required: false 28 | default: '1.29.2' 29 | registry: 30 | description: 'Docker registry' 31 | required: true 32 | login: 33 | description: 'Docker login' 34 | required: false 35 | default: '' 36 | password: 37 | description: 'Docker password' 38 | required: false 39 | default: '' 40 | outputs: {} 41 | runs: 42 | using: "composite" 43 | steps: 44 | - uses: KengoTODA/actions-setup-docker-compose@main 45 | with: 46 | version: ${{ inputs.docker-compose-version }} 47 | 48 | - name: Login 49 | uses: docker/login-action@v3 50 | if: ${{ contains(inputs.registry, '.amazonaws.com') || ( inputs.login != '' && inputs.password != '' ) }} 51 | with: 52 | registry: ${{ inputs.registry }} 53 | username: ${{ inputs.login }} 54 | password: ${{ inputs.password }} 55 | 56 | - name: Start stack 57 | shell: bash 58 | run: | 59 | cd ${{ inputs.workdir }} 60 | docker-compose -f ${{ inputs.file }} pull --include-deps 61 | docker-compose -f ${{ inputs.file }} up -d 62 | 63 | - name: Test 64 | shell: bash 65 | run: | 66 | cd ${{ inputs.workdir }} 67 | DIR=$(pwd) 68 | docker-compose -f ${{ inputs.file }} run -v ${DIR}:/github_workspace -w /github_workspace --entrypoint ${{ inputs.entrypoint }} --rm ${{ inputs.service }} -- ${{ inputs.command }} 69 | 70 | - name: Stop stacks 71 | if: always() 72 | shell: bash 73 | run: | 74 | cd ${{ inputs.workdir }} 75 | docker-compose -f ${{ inputs.file }} down 76 | 77 | 78 | -------------------------------------------------------------------------------- /docs/github-action.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Inputs 4 | 5 | | Name | Description | Default | Required | 6 | |------|-------------|---------|----------| 7 | | command | Command to run tests | N/A | true | 8 | | docker-compose-version | Docker compose version | 1.29.2 | false | 9 | | entrypoint | Entrypoint | /bin/sh | false | 10 | | file | Docker compose file | N/A | true | 11 | | login | Docker login | | false | 12 | | password | Docker password | | false | 13 | | registry | Docker registry | N/A | true | 14 | | service | Service run tests inside | N/A | true | 15 | | workdir | Working directory | ./ | false | 16 | 17 | 18 | ## Outputs 19 | 20 | | Name | Description | 21 | |------|-------------| 22 | 23 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:base" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /tests/fixtures/test/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | app: 4 | image: nginx:1.23.0-alpine 5 | -------------------------------------------------------------------------------- /tests/fixtures/test/test-failure.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -ex 4 | 5 | echo "Test failed" 6 | 7 | exit 1 -------------------------------------------------------------------------------- /tests/fixtures/test/test-success.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -ex 4 | 5 | echo "Test passed" 6 | 7 | exit 0 --------------------------------------------------------------------------------