diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..85184b7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/keepalive.yml b/.github/workflows/keepalive.yml new file mode 100644 index 0000000..9f5bb24 --- /dev/null +++ b/.github/workflows/keepalive.yml @@ -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 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 189d54e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: php - -php: - - 7.3 - -before_script: - - composer install --dev - -script: - - vendor/bin/phpunit - - vendor/bin/phpcs --standard=PSR2 src tests diff --git a/README.md b/README.md index 2086cfb..45756be 100644 --- a/README.md +++ b/README.md @@ -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). @@ -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 @@ -57,16 +55,16 @@ Parameters: * `q`: (required) Class name, method name (`::()` or ->()`), as well as property name ((`::$` or ->`). - * `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 diff --git a/conf/doctum.json b/conf/doctum.json index 7acd052..4831b77 100644 --- a/conf/doctum.json +++ b/conf/doctum.json @@ -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" }, @@ -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" @@ -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" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 374d6dd..d797431 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,8 @@ + - - - tests - - + + + tests + + diff --git a/search/lookup.php b/search/lookup.php index 4d6d786..209fac3 100644 --- a/search/lookup.php +++ b/search/lookup.php @@ -8,7 +8,6 @@ $lookup = new SilverStripe\ApiDocs\Lookup($_GET); $lookup->setVersionMap(array( - 'master' => '5', '/^(\d+)[.].*$/' => '$1', )); diff --git a/src/Lookup.php b/src/Lookup.php index c09fe77..719d63b 100644 --- a/src/Lookup.php +++ b/src/Lookup.php @@ -14,7 +14,7 @@ class Lookup * * @var string */ - const DEFAULT_BRANCH = 'master'; + const DEFAULT_BRANCH = '4'; /** * @var string[] @@ -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 */ diff --git a/tests/LookupTest.php b/tests/LookupTest.php index 6c85a9c..c12cb5c 100644 --- a/tests/LookupTest.php +++ b/tests/LookupTest.php @@ -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', ]); diff --git a/tests/SilverStripeRemoteRepositoryTest.php b/tests/SilverStripeRemoteRepositoryTest.php index 154e018..8eb75a1 100644 --- a/tests/SilverStripeRemoteRepositoryTest.php +++ b/tests/SilverStripeRemoteRepositoryTest.php @@ -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 );