Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d041e3f26 |
No files matched your search
@@ -31,8 +31,6 @@ jobs:
|
|||||||
languages.append('javascript-typescript')
|
languages.append('javascript-typescript')
|
||||||
if '.py' in extensions:
|
if '.py' in extensions:
|
||||||
languages.append('python')
|
languages.append('python')
|
||||||
if '.rb' in extensions:
|
|
||||||
languages.append('ruby')
|
|
||||||
if any((name.startswith('.github/workflows/') and PurePosixPath(name).suffix in {'.yml', '.yaml'})
|
if any((name.startswith('.github/workflows/') and PurePosixPath(name).suffix in {'.yml', '.yaml'})
|
||||||
or PurePosixPath(name).name in {'action.yml', 'action.yaml'} for name in files if name):
|
or PurePosixPath(name).name in {'action.yml', 'action.yaml'} for name in files if name):
|
||||||
languages.append('actions')
|
languages.append('actions')
|
||||||
|
|||||||
@@ -533,7 +533,7 @@ def node_artifact_template(config, branch, tag):
|
|||||||
lines = ["registry=https://registry.npmjs.org/"]
|
lines = ["registry=https://registry.npmjs.org/"]
|
||||||
lines += [scope + ":registry=https://npm.pkg.github.com/" for scope in config["npm_scopes"]]
|
lines += [scope + ":registry=https://npm.pkg.github.com/" for scope in config["npm_scopes"]]
|
||||||
if config["npm_scopes"]:
|
if config["npm_scopes"]:
|
||||||
lines.append("//npm.pkg.github.com/:_authToken=${NPM_TOKEN}")
|
lines.append("//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}")
|
||||||
npmrc = "printf '%s\\n' " + " ".join("'" + line + "'" for line in lines) + " >> .npmrc"
|
npmrc = "printf '%s\\n' " + " ".join("'" + line + "'" for line in lines) + " >> .npmrc"
|
||||||
steps = ["checkout", {"run": {"name": "Configure npm registries", "command": npmrc}},
|
steps = ["checkout", {"run": {"name": "Configure npm registries", "command": npmrc}},
|
||||||
{"restore_cache": {"keys": ['node-artifact-npm-v1-{{ checksum "package-lock.json" }}', 'node-artifact-npm-v1-']}},
|
{"restore_cache": {"keys": ['node-artifact-npm-v1-{{ checksum "package-lock.json" }}', 'node-artifact-npm-v1-']}},
|
||||||
|
|||||||
@@ -533,7 +533,7 @@ def node_artifact_template(config, branch, tag):
|
|||||||
lines = ["registry=https://registry.npmjs.org/"]
|
lines = ["registry=https://registry.npmjs.org/"]
|
||||||
lines += [scope + ":registry=https://npm.pkg.github.com/" for scope in config["npm_scopes"]]
|
lines += [scope + ":registry=https://npm.pkg.github.com/" for scope in config["npm_scopes"]]
|
||||||
if config["npm_scopes"]:
|
if config["npm_scopes"]:
|
||||||
lines.append("//npm.pkg.github.com/:_authToken=${NPM_TOKEN}")
|
lines.append("//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}")
|
||||||
npmrc = "printf '%s\\n' " + " ".join("'" + line + "'" for line in lines) + " >> .npmrc"
|
npmrc = "printf '%s\\n' " + " ".join("'" + line + "'" for line in lines) + " >> .npmrc"
|
||||||
steps = ["checkout", {"run": {"name": "Configure npm registries", "command": npmrc}},
|
steps = ["checkout", {"run": {"name": "Configure npm registries", "command": npmrc}},
|
||||||
{"restore_cache": {"keys": ['node-artifact-npm-v1-{{ checksum "package-lock.json" }}', 'node-artifact-npm-v1-']}},
|
{"restore_cache": {"keys": ['node-artifact-npm-v1-{{ checksum "package-lock.json" }}', 'node-artifact-npm-v1-']}},
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ class PipelineTests(unittest.TestCase):
|
|||||||
artifacts = [step["store_artifacts"] for step in steps if isinstance(step, dict) and "store_artifacts" in step]
|
artifacts = [step["store_artifacts"] for step in steps if isinstance(step, dict) and "store_artifacts" in step]
|
||||||
self.assertEqual(int(branch in ("main", "feature/initial-dev")), len(artifacts))
|
self.assertEqual(int(branch in ("main", "feature/initial-dev")), len(artifacts))
|
||||||
self.assertNotIn("npm publish", str(output))
|
self.assertNotIn("npm publish", str(output))
|
||||||
self.assertIn("${NPM_TOKEN}", commands[0])
|
self.assertIn("${GITHUB_TOKEN}", commands[0])
|
||||||
self.assertEqual({"ignore": "/.*/"}, output["workflows"]["verify"]["jobs"][0]["node_artifact"]["filters"]["tags"])
|
self.assertEqual({"ignore": "/.*/"}, output["workflows"]["verify"]["jobs"][0]["node_artifact"]["filters"]["tags"])
|
||||||
|
|
||||||
def test_node_artifact_requires_explicit_minor_or_patch_image(self):
|
def test_node_artifact_requires_explicit_minor_or_patch_image(self):
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
"""GitHub Packages auth stays a literal, host-scoped runtime reference."""
|
||||||
|
import importlib.util
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
spec = importlib.util.spec_from_file_location('pipeline', ROOT / 'src/scripts/generate_pipeline.py')
|
||||||
|
pipeline = importlib.util.module_from_spec(spec)
|
||||||
|
spec.loader.exec_module(pipeline)
|
||||||
|
|
||||||
|
|
||||||
|
class NodeArtifactAuth(unittest.TestCase):
|
||||||
|
def test_registry_configuration_uses_github_credential_without_embedding_it(self):
|
||||||
|
config = {'node_version': '20.19', 'context': 'packages', 'npm_scopes': ['@nocode-js', '@qrunio'],
|
||||||
|
'artifact_path': 'dist/component.js', 'build_branches': ['develop']}
|
||||||
|
command = pipeline.node_artifact_template(config, 'develop', '')['jobs']['node_artifact']['steps'][1]['run']['command']
|
||||||
|
with tempfile.TemporaryDirectory() as directory:
|
||||||
|
env = {**os.environ, 'GITHUB_TOKEN': 'github-fixture-secret', 'NPM_TOKEN': 'npm-fixture-secret'}
|
||||||
|
result = subprocess.run(['bash', '-c', command], cwd=directory, env=env, capture_output=True, text=True)
|
||||||
|
self.assertEqual(result.returncode, 0, result.stderr)
|
||||||
|
contents = (Path(directory) / '.npmrc').read_text()
|
||||||
|
self.assertEqual(contents.splitlines(), ['registry=https://registry.npmjs.org/',
|
||||||
|
'@nocode-js:registry=https://npm.pkg.github.com/', '@qrunio:registry=https://npm.pkg.github.com/',
|
||||||
|
'//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}'])
|
||||||
|
for value in ('github-fixture-secret', 'npm-fixture-secret'):
|
||||||
|
self.assertNotIn(value, contents + result.stdout + result.stderr)
|
||||||
@@ -44,20 +44,8 @@ class BranchLanguages(unittest.TestCase):
|
|||||||
self.assertEqual(0, result.returncode, result.stderr)
|
self.assertEqual(0, result.returncode, result.stderr)
|
||||||
self.assertIn('build-mode=autobuild\n', output)
|
self.assertIn('build-mode=autobuild\n', output)
|
||||||
|
|
||||||
def test_java_cli_preserves_homebrew_ruby_coverage(self):
|
|
||||||
result, output = self.select(['src/Main.java', 'packaging/homebrew/qctl.rb', '.github/workflows/build.yml'])
|
|
||||||
self.assertEqual(0, result.returncode, result.stderr)
|
|
||||||
self.assertIn('languages=java-kotlin,ruby,actions\n', output)
|
|
||||||
self.assertIn('build-mode=none\n', output)
|
|
||||||
|
|
||||||
def test_ruby_only_source_is_supported(self):
|
|
||||||
result, output = self.select(['Formula/qctl.rb'])
|
|
||||||
self.assertEqual(0, result.returncode, result.stderr)
|
|
||||||
self.assertIn('languages=ruby\n', output)
|
|
||||||
self.assertIn('build-mode=none\n', output)
|
|
||||||
|
|
||||||
def test_untracked_files_do_not_select_languages(self):
|
def test_untracked_files_do_not_select_languages(self):
|
||||||
result, output = self.select(['src/Example.java'], ['web/generated.js', 'generated/formula.rb', '.github/workflows/untracked.yml'])
|
result, output = self.select(['src/Example.java'], ['web/generated.js', '.github/workflows/untracked.yml'])
|
||||||
self.assertEqual(0, result.returncode, result.stderr)
|
self.assertEqual(0, result.returncode, result.stderr)
|
||||||
self.assertIn('languages=java-kotlin\n', output)
|
self.assertIn('languages=java-kotlin\n', output)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user