forked from stripe-samples/subscription-use-cases
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Applied the same settings as: - stripe-samples/accept-a-payment#1385 - stripe-samples/accept-a-payment#1612
- Loading branch information
Showing
5 changed files
with
119 additions
and
62 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,62 @@ | ||
name: CI for stripe-samples/subscription-use-cases | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- fix-ci | ||
- main | ||
- 'main' | ||
pull_request_target: | ||
|
||
env: | ||
STRIPE_PUBLISHABLE_KEY: ${{ secrets.TEST_STRIPE_PUBLISHABLE_KEY }} | ||
STRIPE_SECRET_KEY: ${{ secrets.TEST_STRIPE_SECRET_KEY }} | ||
PREMIUM: ${{ secrets.TEST_PREMIUM_PRICE }} | ||
BASIC: ${{ secrets.TEST_BASIC_PRICE }} | ||
MAINTAINERS: | | ||
cecilphillip-stripe | ||
charliegerard-stripe | ||
dependabot[bot] | ||
erinkavanaugh-stripe | ||
hideokamoto-stripe | ||
kevinpeters-stripe | ||
paulasjes-stripe | ||
concurrency: | ||
group: ci-${{ github.ref }} | ||
group: ci-${{ github.event.pull_request.head.ref || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
require-permission: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 'check if the triggering actor is one of the maintainers' | ||
run: | | ||
while read item; do | ||
if [[ "$item" == "${{ github.triggering_actor }}" ]]; then | ||
exit # safe to run tests with write permission | ||
fi | ||
done <<< "$MAINTAINERS" | ||
echo 'CI have to be re-run by one of the $MAINTAINERS' >> $GITHUB_STEP_SUMMARY | ||
exit 1 | ||
changed_files: | ||
runs-on: ubuntu-latest | ||
needs: require-permission | ||
outputs: | ||
files: ${{ steps.diff.outputs.files }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.after || github.event.pull_request.head.sha }} | ||
fetch-depth: 0 | ||
|
||
- name: 'Collect changed files' | ||
id: diff | ||
run: | | ||
echo 'files<<EOF' >> $GITHUB_OUTPUT | ||
git diff --name-only --merge-base origin/main >> $GITHUB_OUTPUT | ||
echo 'EOF' >> $GITHUB_OUTPUT | ||
server_test: | ||
runs-on: ubuntu-20.04 | ||
needs: changed_files | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
|
@@ -32,7 +72,7 @@ jobs: | |
- server_type: python | ||
server_image: python:latest | ||
- server_type: python | ||
server_image: python:3.7 | ||
server_image: python:3.8 | ||
- server_type: java | ||
server_image: maven:latest | ||
- server_type: java | ||
|
@@ -58,24 +98,33 @@ jobs: | |
runtime: | ||
server_type: php-slim | ||
steps: | ||
- id: if_running | ||
run: | | ||
prefix="${{ matrix.target.sample }}/server/${{ matrix.runtime.server_type }}" | ||
if [[ "${{ github.event.pull_request.head.ref || github.ref }}" = "refs/heads/main" ]] || \ | ||
[[ $(echo "${{ needs.changed_files.outputs.files }}" | grep -E "^${prefix}") ]] | ||
then echo 'running=true' >> $GITHUB_OUTPUT | ||
fi | ||
- uses: actions/checkout@v3 | ||
if: ${{ steps.if_running.outputs.running }} | ||
with: | ||
ref: ${{ github.event.after || github.event.pull_request.head.sha }} | ||
|
||
- uses: actions/checkout@v3 | ||
if: ${{ steps.if_running.outputs.running }} | ||
with: | ||
repository: 'stripe-samples/sample-ci' | ||
path: 'sample-ci' | ||
|
||
- name: Setup dependencies | ||
run: | | ||
source sample-ci/helpers.sh | ||
setup_dependencies | ||
- name: Run tests | ||
if: ${{ steps.if_running.outputs.running }} | ||
run: | | ||
rm -rf usage-based-subscriptions/server/dotnet/ReportUsage # causes "Program.cs(14,28): error CS0017: Program has more than one entry point defined." | ||
source sample-ci/helpers.sh | ||
setup_dependencies | ||
install_docker_compose_settings | ||
export STRIPE_WEBHOOK_SECRET=$(retrieve_webhook_secret) | ||
|
@@ -89,15 +138,16 @@ jobs: | |
docker-compose exec -T runner bundle exec rspec spec/${{ matrix.target.tests }} | ||
- name: Collect debug information | ||
if: ${{ failure() }} | ||
if: ${{ steps.if_running.outputs.running && failure() }} | ||
run: | | ||
cat .env | ||
cat docker-compose.yml | ||
docker-compose ps -a | ||
docker-compose logs web | ||
e2e_test: | ||
runs-on: ubuntu-20.04 | ||
needs: changed_files | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
|
@@ -114,26 +164,34 @@ jobs: | |
env: | ||
SERVER_URL: ${{ matrix.implementation.server_url }} | ||
steps: | ||
- id: if_running | ||
run: | | ||
prefix="${{ matrix.target.sample }}/client/${{ matrix.implementation.client_type }}" | ||
if [[ "${{ github.event.pull_request.head.ref || github.ref }}" = "refs/heads/main" ]] || \ | ||
[[ $(echo "${{ needs.changed_files.outputs.files }}" | grep -E "^${prefix}") ]] | ||
then echo 'running=true' >> $GITHUB_OUTPUT | ||
fi | ||
- uses: actions/checkout@v3 | ||
if: ${{ steps.if_running.outputs.running }} | ||
with: | ||
ref: ${{ github.event.after || github.event.pull_request.head.sha }} | ||
|
||
- uses: actions/checkout@v3 | ||
if: ${{ steps.if_running.outputs.running }} | ||
with: | ||
repository: 'stripe-samples/sample-ci' | ||
path: 'sample-ci' | ||
|
||
- name: Setup dependencies | ||
run: | | ||
source sample-ci/helpers.sh | ||
setup_dependencies | ||
- name: Prepare tests | ||
- name: Run tests | ||
if: ${{ steps.if_running.outputs.running }} | ||
run: | | ||
echo "$(cat ${{ matrix.target.sample }}/client/react/package.json | jq '.proxy = "http://web:4242"')" > ${{ matrix.target.sample }}/client/react/package.json | ||
echo "$(cat ${{ matrix.target.sample }}/client/${{ matrix.implementation.client_type }}/package.json | jq '.proxy = "http://web:4242"')" > ${{ matrix.target.sample }}/client/${{ matrix.implementation.client_type }}/package.json | ||
ln -s react-cra sample-ci/docker/react | ||
- name: Run tests | ||
run: | | ||
source sample-ci/helpers.sh | ||
setup_dependencies | ||
install_docker_compose_settings | ||
export STRIPE_WEBHOOK_SECRET=$(retrieve_webhook_secret) | ||
|
@@ -143,27 +201,54 @@ jobs: | |
PREMIUM=${{ secrets.TEST_PREMIUM_PRICE }} | ||
EOF | ||
configure_docker_compose_for_integration "${{ matrix.target.sample }}" node ../../client/${{ matrix.implementation.client_type }} node:14.17 | ||
configure_docker_compose_for_integration "${{ matrix.target.sample }}" node ../../client/${{ matrix.implementation.client_type }} node:lts | ||
docker-compose --profile="${{ matrix.implementation.profile }}" up -d && wait_web_server | ||
command="docker-compose exec -T runner bundle exec rspec spec/${{ matrix.target.tests }}" | ||
$command \ | ||
|| $command --only-failures \ | ||
|| $command --only-failures --format RSpec::Github::Formatter --format progress | ||
- name: Collect debug information | ||
if: ${{ failure() }} | ||
if: ${{ steps.if_running.outputs.running && failure() }} | ||
run: | | ||
cat .env | ||
cat docker-compose.yml | ||
docker-compose ps -a | ||
docker-compose --profile="${{ matrix.implementation.profile }}" logs web | ||
docker-compose --profile="${{ matrix.implementation.profile }}" logs web frontend | ||
docker cp $(docker-compose ps -qa runner | head -1):/work/tmp . | ||
- name: Upload capybara screenshots | ||
if: ${{ failure() }} | ||
if: ${{ steps.if_running.outputs.running && failure() }} | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: screenshots | ||
path: | | ||
tmp/capybara | ||
auto-merge-dependabot-prs: | ||
if: ${{ github.event.pull_request && github.actor == 'dependabot[bot]' }} | ||
needs: | ||
- server_test | ||
- e2e_test | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Dependabot metadata | ||
id: metadata | ||
uses: dependabot/[email protected] | ||
with: | ||
github-token: '${{ secrets.GITHUB_TOKEN }}' | ||
- name: Enable auto-merge for Stripe SDKs | ||
if: | | ||
(contains(steps.metadata.outputs.dependency-names, 'github.com/stripe/stripe-go/v72') || | ||
contains(steps.metadata.outputs.dependency-names, 'Stripe.net') || | ||
contains(steps.metadata.outputs.dependency-names, 'com.stripe:stripe-java') || | ||
contains(steps.metadata.outputs.dependency-names, 'stripe/stripe-php') || | ||
contains(steps.metadata.outputs.dependency-names, 'stripe')) | ||
run: gh pr merge --auto --merge "$PR_URL" | ||
env: | ||
PR_URL: ${{github.event.pull_request.html_url}} | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Flask==2.2.3 | ||
Flask==3.0.0 | ||
python-dotenv==1.0.0 | ||
stripe==5.5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Flask==2.2.3 | ||
Flask==3.0.0 | ||
python-dotenv==1.0.0 | ||
stripe==5.5.0 |