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

[Blueprints] Add a github:artifact resource type #1796

Open
adamziel opened this issue Sep 24, 2024 · 1 comment · May be fixed by #1799
Open

[Blueprints] Add a github:artifact resource type #1796

adamziel opened this issue Sep 24, 2024 · 1 comment · May be fixed by #1799

Comments

@adamziel
Copy link
Collaborator

adamziel commented Sep 24, 2024

GitHub artifacts are difficult to use as Blueprint resources. As doubly zipped archives, they need convoluted peeling. Let's introduce a new resource type called github:artifact that would take handle the peeling for the developer.

What I want the Blueprint to look like

{
	"steps": [
		{
			step: 'installPlugin',
			pluginData: {
				resource: 'github:artifact',
				url: zipArtifactUrl
			},
		}
	]
}

What the Blueprint looks like today

{
	"steps": [
		{
			step: 'mkdir',
			path: '/wordpress/pr',
		},
		/*
		 * This is the most important step.
		 * It download the built plugin zip file exposed by GitHub CI.
		 *
		 * Because the zip file is not publicly accessible, we use the
		 * plugin-proxy API endpoint to download it. The source code of
		 * that endpoint is available at:
		 * https://github.com/WordPress/wordpress-playground/blob/trunk/packages/playground/website/public/plugin-proxy.php
		 */
		{
			step: 'writeFile',
			path: '/wordpress/pr/pr.zip',
			data: {
				resource: 'url',
				url: zipArtifactUrl,
				caption: `Downloading Gutenberg PR ${prNumber}`,
			},
			progress: {
				weight: 2,
				caption: `Applying Gutenberg PR ${prNumber}`,
			},
		},
		/**
		 * GitHub CI artifacts are doubly zipped:
		 *
		 * pr.zip
		 *    gutenberg.zip
		 *       gutenberg.php
		 *       ... other files ...
		 *
		 * This step extracts the inner zip file so that we get
		 * access directly to gutenberg.zip and can use it to
		 * install the plugin.
		 */
		{
			step: 'unzip',
			zipPath: '/wordpress/pr/pr.zip',
			extractToPath: '/wordpress/pr',
		},
		{
			step: 'installPlugin',
			pluginData: {
				resource: 'vfs',
				path: '/wordpress/pr/gutenberg.zip',
			},
		}
	]
}
@adamziel
Copy link
Collaborator Author

Explorations in #1799

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant