Skip to content

Commit

Permalink
Fix CHANGELOG and improve CI and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dvacca-onfido committed Jun 13, 2024
1 parent 2427a39 commit cffbf80
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 10 deletions.
40 changes: 35 additions & 5 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ jobs:
node-version: [16.x, 18.x, 20.x, 21.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
Expand All @@ -46,8 +46,7 @@ jobs:
run: npx prettier -c test/**/*.ts
- name: Run integration tests with NPM
if: ${{ matrix.node-version == '16.x' &&
github.repository_owner == 'onfido' &&
github.actor != 'dependabot[bot]' }}
github.repository_owner == 'onfido' }}
run: npm test -- -i
env:
ONFIDO_API_TOKEN: ${{ secrets.ONFIDO_API_TOKEN }}
Expand All @@ -61,9 +60,12 @@ jobs:
runs-on: ubuntu-latest

needs: integration-tests
environment: delivery
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_ACTION_ACCESS_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version: 16.x
Expand All @@ -75,3 +77,31 @@ jobs:
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
- name: Update CHANGELOG.md
run: |
TMP_FILE=$(mktemp)
RELEASE_VERSION=$(jq -r '.release' .release.json)
RELEASE_DATE=`date +'%dth %B %Y' | sed -E 's/^0//;s/^([2,3]?)1th/\11st/;s/^([2]?)2th/\12nd/;s/^([2]?)3th/\13rd/'`
SPEC_COMMIT_SHA=$(jq -r '.source.short_sha' .release.json)
SPEC_COMMIT_URL=$(jq -r '.source.repo_url + "/commit/" + .source.long_sha' .release.json)
SPEC_RELEASE_VERSION=$(jq -r '.source.version' .release.json)
SPEC_RELEASE_URL=$(jq -r '.source.repo_url + "/releases/tag/" + .source.version' .release.json)
echo -e "# Changelog\n\n## $RELEASE_VERSION $RELEASE_DATE\n\n" >| $TMP_FILE
echo -en "${{ github.event.release.body }}\nBased on Onfido OpenAPI spec " >> $TMP_FILE
if [ -z $SPEC_RELEASE_VERSION ]; then
echo "up to commit [$SPEC_COMMIT_SHA](${SPEC_COMMIT_URL})." >> $TMP_FILE
else
echo "version [$SPEC_RELEASE_VERSION](${SPEC_RELEASE_URL})." >> $TMP_FILE
fi
grep -v "^# Changelog" CHANGELOG.md >> $TMP_FILE
mv $TMP_FILE CHANGELOG.md
git config user.name "GitHub Actions Bot"
git config user.email "<>"
git commit -m "Update CHANGELOG.md after library release" CHANGELOG.md
git push
4 changes: 0 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Changelog

## v4.0.0 10th June 2024

- Refresh library up to commit: [62dc554](https://github.com/onfido/onfido-openapi-spec/commit/62dc5541a4a51e8de313fc99fb3dec496033a23e)

## v3.0.0 6th May 2024 (pre-release)

- Make library auto-generated and based on [Onfido OpenAPI spec](https://github.com/onfido/onfido-openapi-spec)
Expand Down
16 changes: 15 additions & 1 deletion test/resources/report-schemas.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { Applicant, Check, Document, Report } from "onfido-node";
import {
Applicant,
Check,
Document,
DocumentReport,
Report
} from "onfido-node";
import {
exampleDocumentReport,
exampleFacialSimilarityPhotoReport
Expand Down Expand Up @@ -41,6 +47,14 @@ it("schema of document report should be valid", async () => {
);

expect(report).toEqual(getExpectedDocumentReport(exampleDocumentReport));
expect(report.name).toEqual("document");

const document_report = report as DocumentReport;

expect(
document_report.breakdown.data_comparison.breakdown.issuing_country.result
).toEqual("clear");
expect(document_report.properties.date_of_birth).toEqual("1990-01-01");
}, 30000);

it("schema of facial similarity photo report should be valid", async () => {
Expand Down

0 comments on commit cffbf80

Please sign in to comment.