Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: auto-trigger code sample testing #1367

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/test-code-samples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test API Docs Code Samples

on:
push:
paths:
- 'apify-api/openapi/code_samples/**'
pull_request:
paths:
- 'apify-api/openapi/code_samples/**'

jobs:
run-code-sample-tests:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Get current branch name
m-murasovs marked this conversation as resolved.
Show resolved Hide resolved
id: get-branch-name
m-murasovs marked this conversation as resolved.
Show resolved Hide resolved
run: echo "branch_name=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV

- name: Call Code Sample Tester Actor
m-murasovs marked this conversation as resolved.
Show resolved Hide resolved
env:
APIFY_TOKEN: ${{ secrets.CODE_SAMPLE_TESTER_ACTOR_TOKEN }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to add a token for this once the actor is moved to the Apify account

BRANCH_NAME: ${{ env.branch_name }}
run: |
curl -X POST "https://api.apify.com/v2/acts/X8D0L4wfpO8fCL1uL/run-sync" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $APIFY_TOKEN" \
-d '{ "branch": "'"$BRANCH_NAME"'" }'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work on PRs from forks?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The run in the console suggests otherwise
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! I've modified the action and the actor so that the owner of the triggering repo is passed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, sorry I deleted that comment because I realised it was wrong, but hadn't seen your second one yet :)

12 changes: 12 additions & 0 deletions apify-api/openapi/code_samples/javascript/actorRun_put.js
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sample is added so that the workflow gets triggered - it's also added in another PR

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const updatedRun = await apifyClient
.run('<RUN ID>')
.update({
statusMessage: 'Actor has finished',
});

console.log(updatedRun);
Loading