-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
118 changed files
with
2,313 additions
and
1,233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,7 @@ on: | |
push: | ||
branches: | ||
- main | ||
- arch | ||
- 'v5.*' | ||
- 3.x | ||
- 2.x | ||
|
||
env: | ||
FORCE_COLOR: 1 | ||
|
@@ -61,6 +58,23 @@ jobs: | |
echo "Setting BASE_COMMIT to $BASE_COMMIT" | ||
echo "BASE_COMMIT=$BASE_COMMIT" >> $GITHUB_ENV | ||
- name: Check user org membership | ||
id: check_user_org_membership | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
echo "Looking up: ${{ github.event.pull_request.user.login }}" | ||
ENCODED_USERNAME=$(printf '%s' '${{ github.event.pull_request.user.login }}' | jq -sRr @uri) | ||
LOOKUP_USER=$(curl --write-out "%{http_code}" --silent --output /dev/null --location "https://api.github.com/orgs/tryghost/members/$ENCODED_USERNAME" --header "Authorization: Bearer ${{ secrets.CANARY_DOCKER_BUILD }}") | ||
if [ "$LOOKUP_USER" == "204" ]; then | ||
echo "User is in the org" | ||
echo "is_member=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "User is not in the org" | ||
echo "is_member=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Determine added packages | ||
uses: dorny/[email protected] | ||
id: added | ||
|
@@ -179,9 +193,8 @@ jobs: | |
changed_any_code: ${{ steps.changed.outputs.any-code }} | ||
changed_new_package: ${{ steps.added.outputs.new-package }} | ||
base_commit: ${{ env.BASE_COMMIT }} | ||
branch_name: ${{ github.ref_name }} | ||
is_canary_branch: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/arch') }} | ||
is_main: ${{ env.IS_MAIN }} | ||
member_is_in_org: ${{ steps.check_user_org_membership.outputs.is_member }} | ||
has_browser_tests_label: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'browser-tests') }} | ||
dependency_cache_key: ${{ env.cachekey }} | ||
|
||
|
@@ -193,7 +206,7 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 100 | ||
fetch-depth: 1000 | ||
- uses: actions/setup-node@v4 | ||
env: | ||
FORCE_COLOR: 0 | ||
|
@@ -419,7 +432,7 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 100 | ||
fetch-depth: 1000 | ||
- uses: actions/setup-node@v4 | ||
env: | ||
FORCE_COLOR: 0 | ||
|
@@ -950,18 +963,98 @@ jobs: | |
] | ||
name: Canary | ||
runs-on: ubuntu-latest | ||
if: always() && needs.job_setup.outputs.is_canary_branch == 'true' && needs.job_setup.result == 'success' && needs.job_required_tests.result == 'success' | ||
if: | | ||
always() | ||
&& needs.job_setup.result == 'success' | ||
&& needs.job_required_tests.result == 'success' | ||
&& ( | ||
needs.job_setup.outputs.is_main == 'true' | ||
|| ( | ||
github.event_name == 'pull_request' | ||
&& needs.job_setup.outputs.member_is_in_org == 'true' | ||
&& contains(github.event.pull_request.labels.*.name, 'deploy-to-staging') | ||
) | ||
) | ||
steps: | ||
- name: Output needs (for debugging) | ||
run: echo "${{ toJson(needs) }}" | ||
|
||
- name: Compute branch name (push) | ||
if: github.event_name == 'push' | ||
run: echo "branch_name=${{ github.ref_name }}" >> $GITHUB_ENV | ||
|
||
- name: Compute branch name (pull_request) | ||
if: github.event_name == 'pull_request' | ||
run: echo "branch_name=${{ github.ref }}" >> $GITHUB_ENV | ||
|
||
- name: Invoke build | ||
uses: aurelien-baudet/workflow-dispatch@v2 | ||
with: | ||
token: ${{ secrets.CANARY_DOCKER_BUILD }} | ||
workflow: .github/workflows/deploy.yml | ||
ref: 'refs/heads/main' | ||
repo: TryGhost/Ghost-Moya | ||
inputs: '{"version":"canary","environment":"staging","version_extra":"${{ needs.job_setup.outputs.branch_name }}"}' | ||
inputs: '{"version":"canary","environment":"staging","version_extra":"${{ env.branch_name }}"}' | ||
wait-for-completion-timeout: 25m | ||
wait-for-completion-interval: 30s | ||
|
||
publish_admin_x_activitypub: | ||
needs: [ | ||
job_setup, | ||
job_lint, | ||
job_unit-tests | ||
] | ||
name: Publish @tryghost/admin-x-activitypub | ||
runs-on: ubuntu-latest | ||
if: always() && needs.job_setup.result == 'success' && needs.job_lint.result == 'success' && needs.job_unit-tests.result == 'success' && needs.job_setup.outputs.is_main == 'true' | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '18.12.1' | ||
|
||
- name: Restore caches | ||
uses: ./.github/actions/restore-cache | ||
env: | ||
DEPENDENCY_CACHE_KEY: ${{ needs.job_setup.outputs.dependency_cache_key }} | ||
|
||
- name: Build the package | ||
run: yarn run nx build @tryghost/admin-x-activitypub | ||
|
||
- name: Check if version changed | ||
id: version_check | ||
working-directory: apps/admin-x-activitypub | ||
run: | | ||
CURRENT_VERSION=$(cat package.json | jq -r .version) | ||
PUBLISHED_VERSION=$(npm show @tryghost/admin-x-activitypub version || echo "0.0.0") | ||
echo "Current version: $CURRENT_VERSION" | ||
echo "Published version: $PUBLISHED_VERSION" | ||
if [ "$CURRENT_VERSION" = "$PUBLISHED_VERSION" ]; then | ||
echo "Version is unchanged." | ||
echo "version_changed=false" >> $GITHUB_ENV | ||
else | ||
echo "Version has changed." | ||
echo "version_changed=true" >> $GITHUB_ENV | ||
fi | ||
- name: Configure .npmrc | ||
run: | | ||
echo "@tryghost:registry=https://registry.npmjs.org/" >> ~/.npmrc | ||
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc | ||
- name: Publish to npm | ||
if: env.version_changed == 'true' | ||
working-directory: apps/admin-x-activitypub | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: npm publish --access public | ||
|
||
- name: Purge jsdelivr cache | ||
if: env.version_changed == 'true' | ||
uses: gacts/purge-jsdelivr-cache@v1 | ||
with: | ||
url: | | ||
https://cdn.jsdelivr.net/npm/@tryghost/admin-x-activitypub@0/dist/admin-x-activitypub.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -580,4 +580,47 @@ describe('ActivityPubAPI', function () { | |
expect(actual).toEqual(expected); | ||
}); | ||
}); | ||
|
||
describe('search', function () { | ||
test('It returns the results of the search', async function () { | ||
const fakeFetch = Fetch({ | ||
'https://auth.api/': { | ||
response: JSONResponse({ | ||
identities: [{ | ||
token: 'fake-token' | ||
}] | ||
}) | ||
}, | ||
'https://activitypub.api/.ghost/activitypub/actions/search?query=%40foo%40bar.baz': { | ||
response: JSONResponse({ | ||
profiles: [ | ||
{ | ||
handle: '@[email protected]', | ||
name: 'Foo Bar' | ||
} | ||
] | ||
}) | ||
} | ||
}); | ||
|
||
const api = new ActivityPubAPI( | ||
new URL('https://activitypub.api'), | ||
new URL('https://auth.api'), | ||
'index', | ||
fakeFetch | ||
); | ||
|
||
const actual = await api.search('@[email protected]'); | ||
const expected = { | ||
profiles: [ | ||
{ | ||
handle: '@[email protected]', | ||
name: 'Foo Bar' | ||
} | ||
] | ||
}; | ||
|
||
expect(actual).toEqual(expected); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.