Skip to content

Commit 4794542

Browse files
committed
Complete rewrite with improved parameter handling and Witness 0.8 support
1 parent d0e3c84 commit 4794542

File tree

74 files changed

+27944
-6520
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+27944
-6520
lines changed

.eslintrc.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"plugins": ["@typescript-eslint"],
4+
"extends": [
5+
"eslint:recommended",
6+
"plugin:@typescript-eslint/recommended"
7+
],
8+
"rules": {
9+
"semi": ["error", "always"],
10+
"quotes": ["error", "double"],
11+
"@typescript-eslint/explicit-function-return-type": "off",
12+
"@typescript-eslint/no-explicit-any": "warn"
13+
},
14+
"env": {
15+
"node": true,
16+
"jest": true
17+
},
18+
"ignorePatterns": ["lib/**/*", "node_modules/**/*", "dist/**/*"]
19+
}

.github/workflows/build-dist.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Build and Update Distribution
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths-ignore:
7+
- 'dist/**'
8+
- '**.md'
9+
10+
jobs:
11+
build-dist:
12+
name: Build dist files
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
token: ${{ secrets.GITHUB_TOKEN }}
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '20'
24+
cache: 'npm'
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Build
30+
run: npm run build
31+
32+
- name: Check for changes
33+
id: git-check
34+
run: |
35+
git add dist/
36+
if git diff --staged --quiet; then
37+
echo "No changes detected"
38+
echo "changes=false" >> $GITHUB_OUTPUT
39+
else
40+
echo "Changes detected"
41+
echo "changes=true" >> $GITHUB_OUTPUT
42+
fi
43+
44+
- name: Commit and push changes
45+
if: steps.git-check.outputs.changes == 'true'
46+
run: |
47+
git config --local user.email "action@github.com"
48+
git config --local user.name "GitHub Action"
49+
git commit -m "Update dist files [skip ci]" -a
50+
git push

.github/workflows/ci.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, feature/* ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: '20'
19+
cache: 'npm'
20+
21+
- name: Install dependencies
22+
run: npm ci
23+
24+
- name: Run tests
25+
run: NODE_ENV=test npm test
26+
27+
# Temporarily disable coverage until we have better test coverage
28+
# - name: Run test coverage
29+
# run: NODE_ENV=test npm run test:coverage
30+
#
31+
# - name: Upload coverage report
32+
# uses: actions/upload-artifact@v4
33+
# with:
34+
# name: coverage-report
35+
# path: coverage/
36+
# if-no-files-found: error
37+
38+
build:
39+
runs-on: ubuntu-latest
40+
needs: test
41+
steps:
42+
- uses: actions/checkout@v4
43+
44+
- name: Setup Node.js
45+
uses: actions/setup-node@v4
46+
with:
47+
node-version: '20'
48+
cache: 'npm'
49+
50+
- name: Install dependencies
51+
run: npm ci
52+
53+
- name: Build
54+
run: npm run build
55+
56+
- name: Check build artifacts
57+
run: |
58+
if [ ! -f "dist/index.js" ]; then
59+
echo "Build failed - dist/index.js does not exist"
60+
exit 1
61+
fi
62+
63+
- name: Upload build artifacts
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: action-dist
67+
path: dist/
68+
if-no-files-found: error

.github/workflows/codeql.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
- cron: '30 1 * * 1' # Run at 1:30 AM UTC on Mondays
10+
11+
jobs:
12+
analyze:
13+
name: Analyze
14+
runs-on: ubuntu-latest
15+
permissions:
16+
actions: read
17+
contents: read
18+
security-events: write
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
language: [ 'javascript' ]
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Initialize CodeQL
30+
uses: github/codeql-action/init@v2
31+
with:
32+
languages: ${{ matrix.language }}
33+
34+
- name: Perform CodeQL Analysis
35+
uses: github/codeql-action/analyze@v2
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Debug Environment
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
debug:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v3
12+
13+
- name: Debug Environment
14+
uses: actions/github-script@v6
15+
with:
16+
script: |
17+
const fs = require('fs');
18+
const { execSync } = require('child_process');
19+
20+
// Print environment variables
21+
console.log('===== ENVIRONMENT VARIABLES =====');
22+
console.log(JSON.stringify(process.env, null, 2));
23+
24+
// Print working directory
25+
console.log('===== WORKING DIRECTORY =====');
26+
console.log(`Current directory: ${process.cwd()}`);
27+
console.log(`Directory contents: ${fs.readdirSync('.').join(', ')}`);
28+
29+
// Print Git status
30+
console.log('===== GIT STATUS =====');
31+
try {
32+
const gitStatus = execSync('git status').toString();
33+
console.log(gitStatus);
34+
35+
const gitLog = execSync('git log -3 --oneline').toString();
36+
console.log('Recent commits:');
37+
console.log(gitLog);
38+
} catch (error) {
39+
console.error(`Git error: ${error.message}`);
40+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Test Action Wrapping
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
permissions:
9+
id-token: write # Required for requesting JWT
10+
contents: read # Required for actions/checkout
11+
12+
jobs:
13+
test-action-wrapper:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v3
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: '16'
23+
24+
- name: Install dependencies
25+
run: npm ci
26+
27+
28+
- name: Test Sigstore Archivista (Original Example)
29+
id: sigstore-attestation
30+
uses: ./
31+
with:
32+
action-ref: "actions/hello-world-javascript-action@main"
33+
who-to-greet: "SigstoreNoPrefix"
34+
step: test-sigstore
35+
attestations: "environment github slsa"
36+
attestor-slsa-export: "true"
37+
enable-sigstore: "true"
38+
enable-archivista: "true"
39+
40+
41+
test-action:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Check out repository
45+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
46+
47+
- name: Run your action with sigstore and Archivista
48+
uses: ./ # Replace this with the path to your action if different
49+
with:
50+
step: test
51+
command: echo hello > hello.txt
52+
enable-sigstore: true
53+
enable-archivista: true
54+
attestations: environment git github slsa
55+
attestor-slsa-export: true
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Test Boolean Input Handling
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
test-boolean-handling:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v3
12+
13+
- name: Debug with Boolean Parameters
14+
uses: ./
15+
with:
16+
step: boolean-test
17+
action-ref: actions/github-script@v6
18+
string-input: "String value test"
19+
boolean-input: false
20+
install-only: true
21+
script: |
22+
console.log("=== BOOLEAN INPUT TEST ===");
23+
console.log("All environment variables:");
24+
Object.keys(process.env)
25+
.filter(key => key.startsWith('INPUT_'))
26+
.forEach(key => {
27+
console.log(`${key}=${process.env[key]} (type: ${typeof process.env[key]})`);
28+
29+
// Check if this is a boolean-like value
30+
if (process.env[key] === 'true' || process.env[key] === 'false') {
31+
console.log(` BOOLEAN VALUE DETECTED: ${key}`);
32+
}
33+
});
34+
35+
// Test boolean handling
36+
console.log("\nBoolean Input Test:");
37+
console.log(`INPUT_BOOLEAN_INPUT=${process.env.INPUT_BOOLEAN_INPUT}`);
38+
console.log(`INPUT_INSTALL_ONLY=${process.env.INPUT_INSTALL_ONLY}`);
39+
40+
// Test what happens when converting these values
41+
console.log("\nBoolean conversion test:");
42+
// Using explicit boolean conversion
43+
console.log(`String 'true' to Boolean: ${Boolean('true')}`);
44+
console.log(`String 'false' to Boolean: ${Boolean('false')}`);
45+
// Using implicit conversion
46+
console.log(`if('true'): ${('true') ? 'truthy' : 'falsy'}`);
47+
console.log(`if('false'): ${('false') ? 'truthy' : 'falsy'}`);

0 commit comments

Comments
 (0)