Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: canonical/chisel
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: cjdcordeiro/chisel
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: tester
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 12 commits
  • 9 files changed
  • 1 contributor

Commits on Jun 11, 2024

  1. Verified

    This commit was signed with the committer’s verified signature.
    cjdcordeiro Cristovao Cordeiro
    Copy the full SHA
    4d43750 View commit details

Commits on Jun 12, 2024

  1. ci: add job for tics static code analysis

    cjdcordeiro committed Jun 12, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    cjdcordeiro Cristovao Cordeiro
    Copy the full SHA
    29373a6 View commit details
  2. fix(ci): secrets are not accessible from forks

    Use a pull_request_target event instead, which runs
    on the context of the base repo. As such, this
    commit makes the definition of the project repo and
    ref explicit, such that the TiCS job can still
    analyze the PR's code, but without running
    potentially harmful CI scripts from the author.
    cjdcordeiro committed Jun 12, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    cjdcordeiro Cristovao Cordeiro
    Copy the full SHA
    b513147 View commit details

Commits on Jul 18, 2024

  1. test: tics in client mode without token

    cjdcordeiro committed Jul 18, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    cjdcordeiro Cristovao Cordeiro
    Copy the full SHA
    7c793a8 View commit details

Commits on Dec 11, 2024

  1. Merge branch 'main' into ROCKS-1209/ci-integration-with-tics

    cjdcordeiro authored Dec 11, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    4da3eb5 View commit details
  2. test: tics

    cjdcordeiro committed Dec 11, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    cjdcordeiro Cristovao Cordeiro
    Copy the full SHA
    dd3825e View commit details

Commits on Jan 16, 2025

  1. Merge branch 'main' of https://github.com/canonical/chisel into ROCKS…

    …-1209/ci-integration-with-tics
    cjdcordeiro committed Jan 16, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    cjdcordeiro Cristovao Cordeiro
    Copy the full SHA
    b5627e5 View commit details

Commits on Jan 17, 2025

  1. ci(tics): test 34429-pull_request_target version

    cjdcordeiro committed Jan 17, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    cjdcordeiro Cristovao Cordeiro
    Copy the full SHA
    aa9f244 View commit details
  2. ci(tics): pin tics action to v3

    cjdcordeiro committed Jan 17, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    cjdcordeiro Cristovao Cordeiro
    Copy the full SHA
    3d0284d View commit details
  3. ci(tics): dynamically infer file list

    cjdcordeiro committed Jan 17, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    cjdcordeiro Cristovao Cordeiro
    Copy the full SHA
    a4209ec View commit details
  4. test

    cjdcordeiro committed Jan 17, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    cjdcordeiro Cristovao Cordeiro
    Copy the full SHA
    ca8f9ef View commit details
  5. test

    cjdcordeiro committed Jan 17, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    cjdcordeiro Cristovao Cordeiro
    Copy the full SHA
    73a0ed9 View commit details
30 changes: 30 additions & 0 deletions .github/actions/build-chisel/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "Build chisel"
description: >
Generates the version file and builds chisel from the current project directory.
The build can be configured via Go environment variables.
outputs:
CHISEL_VERSION:
description: "The chisel version"
value: ${{ steps.build.outputs.chisel-version }}
runs:
using: "composite"
steps:
- id: build
shell: bash
run: |
echo "Generating version file"
go generate ./cmd/
echo "Building for $GOOS $GOARCH"
go build -trimpath -ldflags='-s -w' ./cmd/chisel
# Get version via "chisel version" to ensure it matches that exactly
CHISEL_VERSION=$(GOOS=linux GOARCH=amd64 go run ./cmd/chisel version)
echo "Version: $CHISEL_VERSION"
# Version should not be "unknown"
[ "$CHISEL_VERSION" != "unknown" ] || exit 1
# Share variables with subsequent steps
echo "chisel-version=${CHISEL_VERSION}" >>$GITHUB_OUTPUT
19 changes: 2 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -51,28 +51,13 @@ jobs:
with:
go-version-file: 'go.mod'

- name: Build Chisel for linux/${{ matrix.arch }}
- uses: ./.github/actions/build-chisel/
name: Build Chisel for linux/${{ matrix.arch }}
id: build
env:
GOOS: "linux"
GOARCH: ${{ matrix.arch }}
CGO_ENABLED: "0"
run: |
echo "Generating version file"
go generate ./cmd/
echo "Building for $GOOS $GOARCH"
go build -trimpath -ldflags='-s -w' ./cmd/chisel
# Get version via "chisel version" to ensure it matches that exactly
CHISEL_VERSION=$(GOOS=linux GOARCH=amd64 go run ./cmd/chisel version)
echo "Version: $CHISEL_VERSION"
# Version should not be "unknown"
[ "$CHISEL_VERSION" != "unknown" ] || exit 1
# Share variables with subsequent steps
echo "CHISEL_VERSION=${CHISEL_VERSION}" >>$GITHUB_OUTPUT

- name: Test if is executable
run: test -x ./chisel
34 changes: 29 additions & 5 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
name: Tests

on:
workflow_call:
inputs:
repository:
description: 'Repository name (with owner) to clone'
required: true
type: string
ref:
description: 'The branch, tag or SHA to checkout'
required: true
type: string
outputs:
test-coverage-file:
description: 'The name of the coverage report file'
value: ${{ jobs.unit-tests.outputs.test-coverage-file }}
test-coverage-artifact:
description: 'The name used to upload the coverage file as a GH artifact'
value: ${{ jobs.unit-tests.outputs.test-coverage-artifact }}
workflow_dispatch:
push:
paths-ignore:
@@ -14,9 +31,16 @@ jobs:
name: Unit Tests
env:
TEST_COVERAGE_FILE: test-coverage.out
TEST_COVERAGE_ARTIFACT: chisel-test-coverage
TEST_COVERAGE_HTML_FILE: test-coverage.html
outputs:
test-coverage-file: ${{ env.TEST_COVERAGE_FILE }}
test-coverage-artifact: ${{ env.TEST_COVERAGE_ARTIFACT }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_call' && inputs.ref || '' }}
repository: ${{ github.event_name == 'workflow_call' && inputs.repository || '' }}

- uses: actions/setup-go@v3
with:
@@ -36,13 +60,13 @@ jobs:
-o=${TEST_COVERAGE_HTML_FILE}
fi
- name: Upload HTML test coverage
uses: actions/upload-artifact@v3
- name: Upload test coverage
uses: actions/upload-artifact@v4
if: always()
continue-on-error: true
with:
name: chisel-test-coverage.html
path: ./*.html
name: ${{ env.TEST_COVERAGE_ARTIFACT }}
path: ./test-coverage*

real-archive-tests:
# Do not change to newer releases as "fips" may not be available there.
128 changes: 128 additions & 0 deletions .github/workflows/tics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: TiCS

on:
workflow_dispatch:
push:
branches: [main]
# Running on pull_request_target instead of pull_request because this workflow
# uses secrets, and thus we need to ensure it runs under this project's code base.
pull_request_target:
branches: [main]
schedule:
- cron: '0 10 * * *'

jobs:
set-project:
# This is needed because pull_request_target events will run workflows in
# the context of the base repository (the repository receiving the pull request).
#
# This means that, for such events, we need to explicitly tell the job to
# "action/checkout" the forked repository/ref (aka source of the PR).
name: Set project environment
runs-on: ubuntu-latest
outputs:
ref: ${{ steps.get-ref.outputs.ref }}
repo: ${{ steps.get-repo.outputs.repo }}
steps:
- id: get-ref
run: echo "ref=${{ github.event_name == 'pull_request_target' && github.head_ref || '' }}" >> $GITHUB_OUTPUT

- id: get-repo
run: echo "repo=${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name || '' }}" >> $GITHUB_OUTPUT

# This is safe because the reusable workflow does not require secrets and this
# call is not setting secret inheritance (i.e. "secrets: inherit")
call-unit-tests:
uses: ./.github/workflows/tests.yaml
needs: [set-project]
with:
ref: ${{ needs.set-project.outputs.ref }}
repository: ${{ needs.set-project.outputs.repo }}

tics-static-code-analysis:
runs-on: ubuntu-24.04
name: TiCS Static Code Analysis
needs: [set-project, call-unit-tests]
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.set-project.outputs.ref }}
repository: ${{ needs.set-project.outputs.repo }}

- name: Check changed paths in PR
id: changed-paths
if: github.event_name == 'pull_request_target'
uses: dorny/paths-filter@v3
with:
filters: |
any:
- "**/*"
list-files: csv

- id: get-filelist
name: List of files to analyze
run: |
if [[ "${{ github.event_name }}" == "pull_request_target" ]]
then
echo "${{ steps.changed-paths.outputs.any_files }}" | tr "," "\n" > ${TICS_FILELIST}
else
echo "." > ${TICS_FILELIST}
fi
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'

- uses: actions/download-artifact@v4

# This is safe because actions do not have access to secrets unless these
# are passed via inputs or environment variables.
# Ref: https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#accessing-your-secrets
- uses: ./.github/actions/build-chisel/
name: Build Chisel (TiCS analysis precondition)
env:
CGO_ENABLED: "0"

# Get the coverage file produced by the unit tests workflow and get it
# ready for TiCS.
- name: Prepare cobertura XML results
env:
TICS_COVERAGE_FOLDER: ".coverage"
run: |
set -x
mkdir -p ${TICS_COVERAGE_FOLDER}
go install github.com/boumenot/gocover-cobertura@latest
gocover-cobertura \
< ${{ needs.call-unit-tests.outputs.test-coverage-artifact }}/${{ needs.call-unit-tests.outputs.test-coverage-file }} \
> ${TICS_COVERAGE_FOLDER}/coverage.xml
- run: go install honnef.co/go/tools/cmd/staticcheck@latest

- name: Run TiCS client analysis
uses: tiobe/tics-github-action@v3
if: github.event_name == 'pull_request_target'
with:
mode: 'client'
codetype: 'TESTCODE'
project: chisel
filelist: ${{ steps.get-filelist.outputs.TICS_FILELIST }}
viewerUrl: 'https://canonical.tiobe.com/tiobeweb/TICS/api/cfg?name=default'
displayUrl: 'https://canonical.tiobe.com/tiobeweb/TICS'
ticsAuthToken: ${{ secrets.TICSAUTHTOKEN }}
installTics: true

- name: Run TiCS server analysis
uses: tiobe/tics-github-action@v3
if: github.event_name != 'pull_request_target'
with:
mode: 'qserver'
codetype: 'PRODUCTION'
project: chisel
branchdir: .
filelist: ${{ steps.get-filelist.outputs.TICS_FILELIST }}
viewerUrl: 'https://canonical.tiobe.com/tiobeweb/TICS/api/cfg?name=default'
displayUrl: 'https://canonical.tiobe.com/tiobeweb/TICS'
ticsAuthToken: ${{ secrets.TICSAUTHTOKEN }}
installTics: true
1 change: 1 addition & 0 deletions cmd/chisel/cmd_info.go
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ import (
"github.com/canonical/chisel/internal/setup"
)

// TODO Add --format flag
var shortInfoHelp = "Show information about package slices"
var longInfoHelp = `
The info command shows detailed information about package slices.
1 change: 1 addition & 0 deletions cmd/chisel/main_test.go
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ import (
// Hook up check.v1 into the "go test" runner
func Test(t *testing.T) { TestingT(t) }

// Hook up check.v1 into the "go test" runner
type BaseChiselSuite struct {
testutil.BaseTest
stdin *bytes.Buffer
1 change: 1 addition & 0 deletions internal/cache/cache.go
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ import (
"time"
)

// DefaultDir returns the default directory for the cache.
func DefaultDir(suffix string) string {
cacheDir := os.Getenv("XDG_CACHE_HOME")
if cacheDir == "" {
1 change: 1 addition & 0 deletions internal/fsutil/create.go
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ import (
"path/filepath"
)

// asdasdasdasd
type CreateOptions struct {
Path string
Mode fs.FileMode
1 change: 1 addition & 0 deletions internal/fsutil/suite_test.go
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ func Test(t *testing.T) { TestingT(t) }

type S struct{}

// asdasdsad
var _ = Suite(&S{})

func (s *S) SetUpTest(c *C) {