Skip to content

Commit

Permalink
Enable automated e2e testing and releases (#850)
Browse files Browse the repository at this point in the history
Co-authored-by: Azeem Shaikh <azeems@google.com>
Co-authored-by: Abhishek Arya <inferno@chromium.org>
  • Loading branch information
3 people committed Aug 12, 2021
1 parent 3f9431d commit 29fbdae
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 9 deletions.
7 changes: 6 additions & 1 deletion cron/bq/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"log"
"net/http"
"strconv"
Expand Down Expand Up @@ -127,7 +128,11 @@ func transferDataToBq(ctx context.Context,
return fmt.Errorf("error during http.Post to %s: %w", webhookURL, err)
}
defer resp.Body.Close()
log.Println(resp.Status)
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("error reading resp.Body: %w", err)
}
log.Printf("Returned status: %s %s", resp.Status, body)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion cron/k8s/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ spec:
restartPolicy: Never
containers:
- name: controller
image: gcr.io/openssf/scorecard-batch-controller:latest
image: gcr.io/openssf/scorecard-batch-controller:stable
args: ["cron/data/projects.csv"]
imagePullPolicy: Always
resources:
Expand Down
2 changes: 2 additions & 0 deletions cron/k8s/transfer.release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ spec:
value: "gs://ossf-scorecard-data-releasetest"
- name: SCORECARD_BIGQUERY_TABLE
value: "scorecard_releasetest"
- name: SCORECARD_WEBHOOK_URL
value: "http://10.4.8.246/"
resources:
limits:
memory: 1Gi
Expand Down
2 changes: 1 addition & 1 deletion cron/k8s/transfer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec:
spec:
containers:
- name: bq-transfer
image: gcr.io/openssf/scorecard-bq-transfer:latest
image: gcr.io/openssf/scorecard-bq-transfer:stable
imagePullPolicy: Always
resources:
limits:
Expand Down
18 changes: 14 additions & 4 deletions cron/k8s/webhook.release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: Service
metadata:
name: scorecard-releasetest-service
spec:
clusterIP: 10.4.8.246
selector:
app.kubernetes.io/name: webhook-releasetest
ports:
- protocol: TCP
port: 80
targetPort: 8080
---

apiVersion: apps/v1
kind: Deployment
metadata:
Expand All @@ -30,10 +44,6 @@ spec:
- name: webhook-releasetest
image: gcr.io/openssf/scorecard-webhook-releasetest:latest
imagePullPolicy: Always
ports:
- protocol: TCP
port: 80
targetPort: 8080
strategy:
type: "RollingUpdate"
rollingUpdate:
Expand Down
2 changes: 1 addition & 1 deletion cron/k8s/worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
spec:
containers:
- name: worker
image: gcr.io/openssf/scorecard-batch-worker
image: gcr.io/openssf/scorecard-batch-worker:stable
args: ["--ignoreRuntimeErrors=true"]
imagePullPolicy: Always
env:
Expand Down
9 changes: 8 additions & 1 deletion cron/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"net/http"

"github.com/google/go-containerregistry/pkg/crane"
"github.com/google/go-containerregistry/pkg/v1/google"
"google.golang.org/protobuf/encoding/protojson"

"github.com/ossf/scorecard/v2/cron/data"
Expand Down Expand Up @@ -51,9 +52,15 @@ func scriptHandler(w http.ResponseWriter, r *http.Request) {
http.StatusBadRequest)
return
}
authn, err := google.NewEnvAuthenticator()
if err != nil {
http.Error(w, fmt.Sprintf("error in NewEnvAuthenticator: %v", err), http.StatusInternalServerError)
return
}
for _, image := range images {
if err := crane.Tag(
fmt.Sprintf("%s:%s", image, metadata.GetCommitSha()), stableTag); err != nil {
fmt.Sprintf("%s:%s", image, metadata.GetCommitSha()), stableTag,
crane.WithAuth(authn)); err != nil {
http.Error(w, fmt.Sprintf("crane.Tag: %v", err), http.StatusInternalServerError)
return
}
Expand Down

0 comments on commit 29fbdae

Please sign in to comment.