Skip to content

Commit

Permalink
update github workflow action
Browse files Browse the repository at this point in the history
  • Loading branch information
stepanjakl committed May 10, 2024
1 parent d71213a commit 93bc1a9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
23 changes: 20 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,32 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
node-version: 22.x

- name: Set up MongoDB
uses: supercharge/mongodb-github-action@v1
with:
mongodb-version: 7
mongodb-version: 7.0

- name: Install Dependencies
run: npm install
run: |
apt update
apt install net-tools -y
mkdir -p tmp
ls
curl -s https://api.github.com/repos/stripe/stripe-mock/releases/latest | jq -r '.assets[] | select(.name | contains("linux_amd64") and endswith(".tar.gz")) | .browser_download_url' | xargs -I{} sh -c 'echo "Downloading {}" && curl -L {} -o tmp/stripe-mock.tar.gz'
tar -xvf tmp/stripe-mock.tar.gz -C tmp
mv tmp/stripe-mock /usr/local/bin/
chmod -R 755 /usr/local/bin/stripe-mock
rm tmp/stripe-mock.tar.gz
npm install
npm install pm2 -g
- name: Start stripe-mock
run: pm2 start --name stripe-mock stripe-mock -- -http-addr 127.0.0.1:12111 -https-addr 127.0.0.1:12112

- name: Display active connections
run: netstat -tuln

- name: Run ESLint
run: npm run eslint
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,4 @@ The `stripe-products` module contains a custom API route (`'/api/v1/stripe-produ
## TODOs (Limitations)

- fix disappering `stripeProductObject` and `stripePriceObject` data when moved between `draft` and `published` modes and vice versa
- mention stripe-mock in the `README`
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ if (process.env.STRIPE_TEST_MODE === 'false') {
} else {
// Using Stripe test mode settings
stripe = new Stripe('sk_test_xyz', {
host: 'localhost',
host: '127.0.0.1',
protocol: 'http',
port: 12111
});
Expand Down
9 changes: 7 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,21 @@ describe('Apostrophe - Stripe Products Integration Tests', function () {
it('should connect to Stripe API', async function() {
const Stripe = require('stripe');
const stripe = new Stripe('sk_test_xyz', {
host: 'localhost',
host: '127.0.0.1',
protocol: 'http',
port: 12111
port: 12111,
maxNetworkRetries: 3,
timeout: 10 * 1000
});

try {
const paymentMethods = await stripe.paymentMethods.list({ limit: 1 });
assert.strictEqual(paymentMethods.data.length > 0, true);
} catch (error) {
console.error('Error connecting to Stripe API:', error);
if (error.detail?.errors?.length > 0) {
console.error('Error detail:', ...error.detail.errors);
}
throw error;
}
});
Expand Down

0 comments on commit 93bc1a9

Please sign in to comment.