|
| 1 | +name: ci |
| 2 | +concurrency: |
| 3 | + group: "${{github.workflow}}-${{github.ref}}" |
| 4 | + cancel-in-progress: true |
| 5 | +on: |
| 6 | + workflow_dispatch: |
| 7 | + push: |
| 8 | + # branches: |
| 9 | + # - main |
| 10 | + # tags: |
| 11 | + # - v*.*.* |
| 12 | + pull_request: |
| 13 | + # types: [opened, synchronize] |
| 14 | + # branches: |
| 15 | + # - '*' |
| 16 | + |
| 17 | +jobs: |
| 18 | + test: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + ruby: ["3.1", "3.2", "3.3", "3.4", "head"] |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + - run: rm Gemfile.lock |
| 27 | + - uses: ruby/setup-ruby@v1 |
| 28 | + with: |
| 29 | + ruby-version: ${{matrix.ruby}} |
| 30 | + bundler: latest |
| 31 | + bundler-cache: true |
| 32 | + - name: Run tests |
| 33 | + run: bundle exec rake test |
| 34 | + |
| 35 | + package: |
| 36 | + needs: [ "test" ] |
| 37 | + name: "package (${{ matrix.platform }})" |
| 38 | + strategy: |
| 39 | + fail-fast: false |
| 40 | + matrix: |
| 41 | + platform: |
| 42 | + - "ruby" |
| 43 | + - "arm64-darwin" |
| 44 | + - "arm64-linux" |
| 45 | + - "x86_64-darwin" |
| 46 | + - "x86_64-linux" |
| 47 | + runs-on: ubuntu-latest |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v4 |
| 50 | + - run: rm Gemfile.lock |
| 51 | + - uses: ruby/setup-ruby@v1 |
| 52 | + with: |
| 53 | + ruby-version: "3.2" |
| 54 | + bundler: latest |
| 55 | + bundler-cache: true |
| 56 | + - run: "bundle exec rake gem:${{matrix.platform}}" |
| 57 | + - uses: actions/upload-artifact@v4 |
| 58 | + with: |
| 59 | + name: gem-${{matrix.platform}} |
| 60 | + path: pkg |
| 61 | + retention-days: 1 |
| 62 | + |
| 63 | + install-ruby: |
| 64 | + name: "install (ruby)" |
| 65 | + needs: [ "package" ] |
| 66 | + runs-on: ubuntu-latest |
| 67 | + steps: |
| 68 | + - uses: ruby/setup-ruby@v1 |
| 69 | + with: |
| 70 | + ruby-version: "3.2" |
| 71 | + - uses: actions/download-artifact@v4 |
| 72 | + with: |
| 73 | + name: gem-ruby |
| 74 | + path: pkg |
| 75 | + - run: "gem install pkg/ruby-stripe-cli-*.gem" |
| 76 | + - run: "stripe 2>&1 | fgrep 'ERROR: Cannot find the stripe cli executable'" |
| 77 | + |
| 78 | + install-native: |
| 79 | + name: "install (${{ matrix.platform }})" |
| 80 | + needs: [ "package" ] |
| 81 | + strategy: |
| 82 | + fail-fast: false |
| 83 | + matrix: |
| 84 | + ruby: [ "3.4" ] |
| 85 | + platform: |
| 86 | + - "arm64-darwin" |
| 87 | + # - "arm64-linux" |
| 88 | + - "x86_64-darwin" |
| 89 | + - "x86_64-linux" |
| 90 | + include: |
| 91 | + - { platform: arm64-darwin, runs_on: macos-14 } |
| 92 | + # - { platform: arm64-linux, docker_platform: "--platform=linux/arm64/v8" } |
| 93 | + - { platform: x86_64-darwin, runs_on: macos-13 } |
| 94 | + - { platform: x86_64-linux, docker_tag: "-alpine", bootstrap: "apk add build-base &&" } |
| 95 | + runs-on: ${{ matrix.runs_on || 'ubuntu-latest' }} |
| 96 | + steps: |
| 97 | + - uses: actions/download-artifact@v4 |
| 98 | + with: |
| 99 | + name: gem-${{ matrix.platform }} |
| 100 | + path: pkg |
| 101 | + - if: ${{ matrix.runs_on }} |
| 102 | + uses: ruby/setup-ruby@v1 |
| 103 | + with: |
| 104 | + ruby-version: ${{ matrix.ruby }} |
| 105 | + - if: ${{ matrix.runs_on }} |
| 106 | + run: "gem install pkg/ruby-stripe-cli-*.gem" |
| 107 | + - if: ${{ matrix.runs_on }} |
| 108 | + run: "stripe --help" |
| 109 | + - if: ${{ (! matrix.runs_on) && matrix.docker_platform }} |
| 110 | + run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes |
| 111 | + - if: ${{ ! matrix.runs_on }} |
| 112 | + run: | |
| 113 | + docker run --rm -v $PWD:/ruby-strie-cli -w /ruby-strie-cli \ |
| 114 | + ${{ matrix.docker_platform }} ruby:${{ matrix.ruby }}${{ matrix.docker_tag }} \ |
| 115 | + sh -c " |
| 116 | + ${{ matrix.bootstrap }} |
| 117 | + gem install pkg/ruby-stripe-cli-*.gem |
| 118 | + stripe --help |
| 119 | + " |
0 commit comments