railpack

Configure and troubleshoot Railpack builds, with emphasis on RAILPACK_* environment variables, railpack.json overlays, build-plan inspection, local CLI installation and usage, and local BuildKit containers. Use for Railpack provider configuration, custom install/build/start commands, Mise or Apt packages, build or runtime variables and secrets, generated-plan debugging, BUILDKIT_HOST errors, or running Railpack from a release or source checkout.

Install
npx skills add 'https://github.com/railwayapp/railpack/tree/main/.'
Incomplete bundle · no download
main · 21a254fScanned 2026-09-17

Contributors

GitHub-linked commit authors for this SKILL.md at the saved revision. Co-authors and history before file renames are not included.

File history ↗

core/config_test.go

core/config_test.goBrowse 1970 files
View on GitHub
← Back to SKILL.md
package core import (	"encoding/json"	"testing" 	"github.com/google/go-cmp/cmp" 	"github.com/railwayapp/railpack/core/app"	"github.com/railwayapp/railpack/core/config"	"github.com/stretchr/testify/require") func TestGenerateConfigFromEnvironment(t *testing.T) {	tests := []struct {		name     string		envVars  map[string]string		expected string	}{		{			name:    "empty environment",			envVars: map[string]string{},			expected: `{				"steps": {},				"packages": {},				"caches": {},				"deploy": {}			}`,		}, 		{			name: "kitchen sink",			envVars: map[string]string{				"RAILPACK_INSTALL_CMD":         "npm install",				"RAILPACK_BUILD_CMD":           "npm run build",				"RAILPACK_START_CMD":           "npm start",				"RAILPACK_PACKAGES":            "node@18 python@3.9",				"RAILPACK_BUILD_APT_PACKAGES":  "build-essential libssl-dev",				"RAILPACK_DEPLOY_APT_PACKAGES": "libssl-dev",			},			expected: `{				"steps": {					"install": {						"name": "install",						"commands": [							{ "src": ".", "dest": "." },							"npm install"						],						"secrets": ["*"],						"assets": {},						"variables": {}					},					"build": {						"name": "build",						"commands": [							{ "src": ".", "dest": "." },							"npm run build"						],						"secrets": ["*"],						"assets": {},						"variables": {}					}				},				"buildAptPackages": ["build-essential", "libssl-dev"],				"packages": {					"node": "18",					"python": "3.9"				},				"caches": {},				"deploy": {					"startCommand": "npm start",					"aptPackages": ["libssl-dev"]				},				"secrets": ["RAILPACK_BUILD_APT_PACKAGES", "RAILPACK_BUILD_CMD", "RAILPACK_DEPLOY_APT_PACKAGES",					"RAILPACK_INSTALL_CMD", "RAILPACK_PACKAGES", "RAILPACK_START_CMD"]			}`,		}, 		{			name: "unversioned packages",			envVars: map[string]string{				"RAILPACK_PACKAGES": "jq pipx:httpie@3.2.4",			},			expected: `{				"steps": {},				"packages": {					"jq": "latest",					"pipx:httpie": "3.2.4"				},				"caches": {},				"deploy": {},				"secrets": ["RAILPACK_PACKAGES"]			}`,		},	} 	for _, tt := range tests {		t.Run(tt.name, func(t *testing.T) {			env := app.NewEnvironment(&tt.envVars)			gotConfig := GenerateConfigFromEnvironment(env) 			serializedConfig := config.Config{}			err := json.Unmarshal([]byte(tt.expected), &serializedConfig)			require.NoError(t, err) 			if diff := cmp.Diff(serializedConfig, *gotConfig); diff != "" {				t.Errorf("GenerateConfigFromEnvironment() mismatch (-want +got):\n%s", diff)			}		})	}}