Skip to content

Commit

Permalink
Merge pull request #102 from creative-commoners/pulls/master/update-c…
Browse files Browse the repository at this point in the history
…ms5-source

FIX Use 5 branch for CMS 5 (not master)
  • Loading branch information
sabina-talipova authored Aug 11, 2022
2 parents a7ddc5c + b669f96 commit 3894fa6
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 49 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:
# Every Monday at 2:20pm UTC
schedule:
- cron: '20 14 * * 1'

jobs:
ci:
name: CI
# Only run cron on the silverstripe account
if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule')
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1
17 changes: 17 additions & 0 deletions .github/workflows/keepalive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Keepalive

on:
# The 4th of every month at 11:20am UTC
schedule:
- cron: '20 11 4 * *'
workflow_dispatch:

jobs:
keepalive:
name: Keepalive
# Only run cron on the silverstripe account
if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule')
runs-on: ubuntu-latest
steps:
- name: Keepalive
uses: silverstripe/gha-keepalive@v1
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Introduction

[![Build Status](https://travis-ci.com/silverstripe/api.silverstripe.org.svg?branch=master)](https://travis-ci.com/silverstripe/api.silverstripe.org)
[![CI](https://github.com/silverstripe/api.silverstripe.org/actions/workflows/ci.yml/badge.svg)](https://github.com/silverstripe/api.silverstripe.org/actions/workflows/ci.yml)

SilverStripe API docs for the core system in different versions,
generated through [Doctum](https://github.com/code-lts/doctum#readme).
Expand Down Expand Up @@ -31,15 +31,13 @@ generated through [Doctum](https://github.com/code-lts/doctum#readme).

### Add a New Version

* Copy a version section block in `doctum.json` and ensure you use the appropriate value for `versionmap` depending
on whether the module started its life at version 1 or version 4 (for SilverStripe 4)
* Copy a version section block in `conf/doctum.json` and ensure you use the appropriate value for `versionmap` - you may need to add more mappings to `versionmap` if the current mappings don't fit all modules for the new major version (e.g. if splitting some functionality off into its own module)
* Run `makedoc.sh` and confirm the generation runs through properly
* Make a commit of the updated `doctum.json`
* Update the redirections in `.htaccess` to the stable version number (if changing major versions)
* Make a commit of the updated `conf/doctum.json`
* Update the redirections in `.htaccess` to the stable version number (if releasing a new stable major version)
* Make a separate commit with the redirection (explained in deployment below)

**Please note:** Often the `master` branch will be representing an unstable major version. When this needs
to be updated, please edit `search/lookup.php`.
**Please note:** If you are changing the default version (i.e. a making a new stable major release), update the default version in `src/Lookup.php`.

### Deployment to production

Expand All @@ -57,16 +55,16 @@ Parameters:

* `q`: (required) Class name, method name (`<class>::<method>()` or <class>-><method>()`),
as well as property name ((`<class>::$<property>` or <class>-><property>`).
* `version`: (optional) Version of the targeted module. Should map to a folder name. Defaults to trunk. Will switch current unstable major version (e.g. 4) to "master".
* `version`: (optional) Version of the targeted module. Should map to a folder name. Default is defined in `src/Lookup.php`.
* `module`: (optional) Module name. Should map to a folder name. Defaults to framework.

Examples:

* `/search/lookup.php?q=DataObject`: Shows `DataObject` docs in `trunk` version of framework
* `/search/lookup.php?q=DataObject`: Shows `DataObject` docs in default version of framework
* `/search/lookup.php?q=DataObject::get()&version=3.0`: Shows `DataObject::get()` docs in `3.0` version of framework
* `/search/lookup.php?q=DataObject::get()&version=3.0`: Shows `DataObject::get()` docs in `3.6` version of framework (or whatever is the latest stable minor version)
* `/search/lookup.php?q=DPSPayment&module=payment`: Shows `DPSPayment` class docs in the `ecommerce` module
* `/search/lookup.php?q=SilverStripe\ORM\DataExtension::onBeforeWrite()&version=4`: Shows `SilverStripe\ORM\DataExtension::onBeforeWrite()` docs in `master` (4.x) version of framework
* `/search/lookup.php?q=SilverStripe\ORM\DataExtension::onBeforeWrite()&version=4`: Shows `SilverStripe\ORM\DataExtension::onBeforeWrite()` docs in (4.x) version of framework

## Contributing

Expand Down
26 changes: 11 additions & 15 deletions conf/doctum.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"theme": "silverstripe",
"base_url": "http://api.silverstripe.org/%version%",
"versions": {
"master": "5.x",
"5": "5.x",
"4": "4.x",
"3": "3.x"
},
Expand All @@ -15,30 +15,30 @@
"packages": {
"silverstripe/admin": {
"repository": "https://github.com/silverstripe/silverstripe-admin.git",
"versionmap": "starts-at-one"
"versionmap": "four-is-one"
},
"silverstripe/asset-admin": {
"repository": "https://github.com/silverstripe/silverstripe-asset-admin.git",
"versionmap": "starts-at-one"
"versionmap": "four-is-one"
},
"silverstripe/assets": {
"repository": "https://github.com/silverstripe/silverstripe-assets.git",
"versionmap": "starts-at-one"
"versionmap": "four-is-one"
},
"silverstripe/campaign-admin": {
"repository": "https://github.com/silverstripe/silverstripe-campaign-admin.git",
"versionmap": "starts-at-one"
"versionmap": "four-is-one"
},
"silverstripe/cms": {
"repository": "https://github.com/silverstripe/silverstripe-cms.git"
},
"silverstripe/config": {
"repository": "https://github.com/silverstripe/silverstripe-config.git",
"versionmap": "starts-at-one"
"versionmap": "four-is-one"
},
"silverstripe/errorpage": {
"repository": "https://github.com/silverstripe/silverstripe-errorpage.git",
"versionmap": "starts-at-one"
"versionmap": "four-is-one"
},
"silverstripe/framework": {
"repository": "https://github.com/silverstripe/silverstripe-framework.git"
Expand All @@ -54,22 +54,18 @@
},
"silverstripe/versioned": {
"repository": "https://github.com/silverstripe/silverstripe-versioned.git",
"versionmap": "starts-at-one"
"versionmap": "four-is-one"
},
"silverstripe/versioned-admin": {
"repository": "https://github.com/silverstripe/silverstripe-versioned-admin.git",
"versionmap": "starts-at-one"
"versionmap": "four-is-one"
}
},
"versionmaps": {
"starts-at-one": {
"master": "master",
"four-is-one": {
"5": "2",
"4": "1",
"3": null
},
"starts-at-three": {
"master": "master",
"4": "3"
}
}

Expand Down
11 changes: 6 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true">
<testsuites>
<testsuite name="SilverStripe API Docs">
<directory>tests</directory>
</testsuite>
</testsuites>
<testsuites>
<testsuite name="Default">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
1 change: 0 additions & 1 deletion search/lookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
$lookup = new SilverStripe\ApiDocs\Lookup($_GET);

$lookup->setVersionMap(array(
'master' => '5',
'/^(\d+)[.].*$/' => '$1',
));

Expand Down
4 changes: 3 additions & 1 deletion src/Lookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Lookup
*
* @var string
*/
const DEFAULT_BRANCH = 'master';
const DEFAULT_BRANCH = '4';

/**
* @var string[]
Expand Down Expand Up @@ -82,6 +82,8 @@ public function handle($return = false)
/**
* Allow setting the "version mapping" that can be used to convert "4" to "master", etc
*
* Useful in the event that modules have strange branching strategies
*
* @param array $map
* @return $this
*/
Expand Down
8 changes: 4 additions & 4 deletions tests/LookupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ public function testGetVersionChecksRegularExpression()

public function testGetVersionExactRule()
{
$lookup = new Lookup(['version' => 'master']);
$lookup = new Lookup(['version' => '5']);
$lookup->setVersionMap([
'master' => '5.x',
'5' => '5',
]);
$this->assertSame('5.x', $lookup->getVersion());
$this->assertSame('5', $lookup->getVersion());
}

public function testGetVersionDefault()
{
$lookup = new Lookup(['version' => 'unknown']);
$lookup->setVersionMap([
'master' => '5.x',
'5' => '5.x',
'4' => '4.x',
'3' => '3.x',
]);
Expand Down
4 changes: 2 additions & 2 deletions tests/SilverStripeRemoteRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ public function testGetRepoUrl()
);

$url = $remoteRepo->getFileUrl(
'master',
'5',
'silverstripe/graphql/src/Extensions/DevBuildExtension.php',
0
);

$this->assertSame(
'https://github.com/silverstripe/'
. 'silverstripe-graphql/blob/master/src/Extensions/DevBuildExtension.php#L0',
. 'silverstripe-graphql/blob/5/src/Extensions/DevBuildExtension.php#L0',
$url
);

Expand Down

0 comments on commit 3894fa6

Please sign in to comment.