Skip to content

Commit

Permalink
test: fix failing tests (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
inigomarquinez authored Mar 14, 2024
1 parent cdd2dec commit 312decc
Show file tree
Hide file tree
Showing 10 changed files with 183 additions and 27 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/release-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Release and publish

on:
push:
branches:
- main

permissions: {}

jobs:
release-please:
runs-on: ubuntu-latest
permissions:
contents: write # to create release commit
pull-requests: write # to create release PR

outputs:
release_created: ${{ steps.release.outputs.release_created }}

steps:
- name: 🆕 Create or update release
uses: google-github-actions/release-please-action@a37ac6e4f6449ce8b3f7607e4d97d0146028dc0b # 4.1.0
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}

npm-publish:
needs: [release-please]
runs-on: ubuntu-latest
permissions:
id-token: write # to allow npm publish provenance generation

# this if statements ensure that a publication only occurs when a new release is created:
if: ${{ needs.release-please.outputs.release_created }}

steps:
- name: 🔐 Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
egress-policy: audit

- name: 🔔 Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1.

- name: ⚙️ Setup Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # 4.0.2
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'

- name: 📦 Install dependencies
run: npm ci

- name: 🚀 Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
20 changes: 0 additions & 20 deletions .github/workflows/release.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/semantic-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Semantic Pull Request

on:
pull_request_target:
types:
- opened
- edited
- synchronize

permissions:
pull-requests: read

jobs:
lint:
name: Validate Pull Request title format
runs-on: ubuntu-latest
steps:
- name: 🔐 Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
egress-policy: audit

- name: 🔎 Validate Pull Request format
uses: amannn/action-semantic-pull-request@e9fabac35e210fea40ca5b14c0da95a099eff26f # v5.4.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Configure additional validation for the subject based on a regex.
# This ensures the subject doesn't start with an uppercase character.
subjectPattern: ^(?![A-Z]).+$
# If `subjectPattern` is configured, you can use this property to override
# the default error message that is shown when the pattern doesn't match.
# The variables `subject` and `title` can be used within the message.
subjectPatternError: |
The subject "{subject}" found in the pull request title "{title}"
didn't match the configured pattern. Please ensure that the subject
doesn't start with an uppercase character.
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
provenance=true
access=public
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.1.0"
}
4 changes: 2 additions & 2 deletions __tests__/e2e/cms/__snapshots__/contentful.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports[`contentful should not fail retrieve array of available entries in defau
},
],
"simpleShortInputTextAreaOne": "Amidst the chaos of dreams, a whisper of serenity finds its way.",
"singleMediaInputField": "https://images.ctfassets.net/tfwqn4ih0op2/36j3phOyWhdSaqhRKeLauu/131db2ba1136b43a16e1a0f4f046c6a0/banner.jpg",
"singleMediaInputField": StringMatching /\\^https:\\\\/\\\\/images\\\\\\.ctfassets\\\\\\.net\\\\/\\.\\+\\\\/banner\\\\\\.jpg\\$/,
},
],
}
Expand All @@ -46,7 +46,7 @@ exports[`contentful should not fail retrieve array of available entries in given
},
],
"simpleShortInputTextAreaOne": "Amidst the chaos of dreams, a whisper of serenity finds its way.",
"singleMediaInputField": "https://images.ctfassets.net/tfwqn4ih0op2/36j3phOyWhdSaqhRKeLauu/8e57bd83434abf21220c1fb5d75efdda/banner.jpg",
"singleMediaInputField": StringMatching /\\^https:\\\\/\\\\/images\\\\\\.ctfassets\\\\\\.net\\\\/\\.\\+\\\\/banner\\\\\\.jpg\\$/,
},
],
}
Expand Down
20 changes: 18 additions & 2 deletions __tests__/e2e/cms/contentful.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@ describe('contentful', () => {
collectionId: process.env.CONTENTFUL_CONTENT_TYPE as string,
});
expect(Array.isArray(harmonizedData.data)).toBeTruthy();
expect(harmonizedData).toMatchSnapshot();
expect(harmonizedData).toMatchSnapshot({
data: [
{
singleMediaInputField: expect.stringMatching(
/^https:\/\/images\.ctfassets\.net\/.+\/banner\.jpg$/,
),
},
],
});
});

it('retrieve array of available entries in given locale (es)', async () => {
Expand All @@ -85,7 +93,15 @@ describe('contentful', () => {
locale: 'es',
});
expect(Array.isArray(harmonizedData.data)).toBeTruthy();
expect(harmonizedData).toMatchSnapshot();
expect(harmonizedData).toMatchSnapshot({
data: [
{
singleMediaInputField: expect.stringMatching(
/^https:\/\/images\.ctfassets\.net\/.+\/banner\.jpg$/,
),
},
],
});
});
});
});
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"name": "@onebeyond/agnostic-cms-harmonizer",
"version": "1.0.0",
"version": "0.1.0",
"description": "Library to manage the communication with any CMS agnostic to the user",
"repository": {
"type": "git",
"url": "git+https://github.com/onebeyond/agnostic-cms-harmonizer.git"
},
"main": "build/src/index.js",
"keywords": [
"cms"
Expand Down
57 changes: 57 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
"release-type": "node",
"pull-request-footer": "This PR was generated with [Release Please](https://github.com/googleapis/release-please).",
"changelog-sections": [
{
"type": "feat",
"section": "🆕 Features",
"hidden": false
},
{
"type": "fix",
"section": "🐛 Bug Fixes",
"hidden": false
},
{
"type": "chore",
"section": "🔧 Others",
"hidden": false
},
{
"type": "docs",
"section": "📝 Docs",
"hidden": false
},
{
"type": "style",
"section": "🎨 Styling",
"hidden": false
},
{
"type": "refactor",
"section": "🔄 Code Refactoring",
"hidden": false
},
{
"type": "perf",
"section": "📈 Performance Improvements",
"hidden": false
},
{
"type": "test",
"section": "🔬 Tests",
"hidden": false
},
{
"type": "ci",
"section": "☁️ CI",
"hidden": false
}
],
"packages": {
".": {
"package-name": ""
}
}
}

0 comments on commit 312decc

Please sign in to comment.